module Fox::FTNonModal

Module to include in FXDialogBox to provide an easy nonmodal version of execute.

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/fox16/execute_nonmodal.rb, line 6
def initialize(*args)
  super if defined?(super)
  FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_CANCEL, :onCmdCancel)
  FXMAPFUNC(SEL_COMMAND, FXDialogBox::ID_ACCEPT, :onCmdAccept)
end

Public Instance Methods

execute_modal(placement = PLACEMENT_CURSOR, &block) click to toggle source

Creates and shows the dialog, and registers the associated block to be called when the dialog is closed. The block is passed a boolean argument which is true if and only if the dialog was accepted.

For example:

dialogBox.execute_modal do |accepted|
  if accepted
    puts "Dialog accepted"
  else
    puts "Dialog cancelled"
 end
# File lib/fox16/execute_nonmodal.rb, line 26
def execute_modal(placement = PLACEMENT_CURSOR, &block)
  @__FTNonModal_block = block
  execute(placement)
end
execute_nonmodal(placement = PLACEMENT_CURSOR, &block) click to toggle source

Creates and shows the dialog, and registers the associated block to be called when the dialog is closed. The block is passed a boolean argument which is true if and only if the dialog was accepted.

For example:

dialogBox.execute_nonmodal do |accepted|
  if accepted
    puts "Dialog accepted"
  else
    puts "Dialog cancelled"
 end
# File lib/fox16/execute_nonmodal.rb, line 45
def execute_nonmodal(placement = PLACEMENT_CURSOR, &block)
  @__FTNonModal_block = block
  create
  show placement
end
on_nonmodal_close(accepted) click to toggle source

Called when dialog is closed, with accepted equal to true if and only if the user accepted the dialog.

# File lib/fox16/execute_nonmodal.rb, line 61
def on_nonmodal_close(accepted)
  @__FTNonModal_block[accepted]

  ##return 0 -- why isn't this enough to close window?
  ## oh well, let's imitate FXTopWindow:
  getApp().stopModal(self, accepted ? 1 : 0)
  hide()
end