Sha256: 7e3f08f94568d6c8ebb5106d4858b5875a95fbfac7344dac28779d1b566b1859

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents



require 'jrubyfx'

# manually create the class

fxml_root File.join(File.dirname(__FILE__),"fx")

class Main
  include JRubyFX::Controller
  fxml "main.fxml"
end

class Main2
  include JRubyFX::Controller
end

class FloatWin
  include JRubyFX::Controller
  fxml "float.fxml"

  def show_context_menu(evt)
    init_ctxmenu.show(@imgFloat, evt.screen_x, evt.screen_y) 
  end


  private
  def init_ctxmenu

    if @ctx.nil?

      @ctx = ContextMenu.new
      mnuItems = []
      @mnuMain = MenuItem.new("G-VCS")
      @mnuMain.on_action do |evt|
        #ctrl = MainWinController.new
        #mainWin = JRubyFX::Controller.get_fxml_loader("main.fxml",ctrl)
        #root = mainWin.load

        stage = javafx.stage.Stage.new
        stage.title = "G-VCS"
        #stage.initModality(javafx.stage.Modality::WINDOW_MODAL)
        #stage.initOwner(@imgFloat.scene.window)
        ctrl = Main.load_into(stage)
        #ctrl = FloatWin.load_into(stage)
        #stage.scene = javafx.scene.Scene.new(root)
        
        stage.show
      end
      mnuItems << @mnuMain

      @mnuExit = MenuItem.new("Exit")
      @mnuExit.on_action do |evt|
        @imgFloat.scene.window.close 
      end
      mnuItems << @mnuExit

      @ctx.items.add_all(mnuItems)

    end

    @ctx
  end



end

class MainApp < JRubyFX::Application
  def start(stage)
    with(stage) do
      fxml FloatWin
      show
    end
  end
end

MainApp.launch


Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gvcsfx-0.6.4 javafx_test.rb
gvcsfx-0.6.3 javafx_test.rb
gvcsfx-0.6.2 javafx_test.rb
gvcsfx-0.6.1 javafx_test.rb
gvcsfx-0.6.0 javafx_test.rb
gvcsfx-0.5.2 javafx_test.rb
gvcsfx-0.5.0 javafx_test.rb
gvcsfx-0.4.2 javafx_test.rb
gvcsfx-0.4.1 javafx_test.rb
gvcsfx-0.3 javafx_test.rb