Module: Fox::FTNonModal
- Defined in:
- lib/fox16/execute_nonmodal.rb
Overview
Module to include in FXDialogBox to provide an easy nonmodal version of execute.
Instance Method Summary collapse
-
#execute_modal(placement = PLACEMENT_CURSOR, &block) ⇒ Object
Creates and shows the dialog, and registers the associated block to be called when the dialog is closed.
-
#execute_nonmodal(placement = PLACEMENT_CURSOR, &block) ⇒ Object
Creates and shows the dialog, and registers the associated block to be called when the dialog is closed.
- #initialize(*args) ⇒ Object
-
#on_nonmodal_close(accepted) ⇒ Object
Called when dialog is closed, with accepted equal to
true
if and only if the user accepted the dialog. -
#onCmdAccept(*args) ⇒ Object
:nodoc:.
-
#onCmdCancel(*args) ⇒ Object
:nodoc:.
Instance Method Details
#execute_modal(placement = PLACEMENT_CURSOR, &block) ⇒ Object
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
26 27 28 29 |
# 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) ⇒ Object
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
45 46 47 48 49 |
# File 'lib/fox16/execute_nonmodal.rb', line 45 def execute_nonmodal(placement = PLACEMENT_CURSOR, &block) @__FTNonModal_block = block create show placement end |
#initialize(*args) ⇒ Object
6 7 8 9 10 |
# 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 |
#on_nonmodal_close(accepted) ⇒ Object
Called when dialog is closed, with accepted equal to true
if and only if the user accepted the dialog.
61 62 63 64 65 66 67 68 |
# 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 |
#onCmdAccept(*args) ⇒ Object
:nodoc:
55 56 57 |
# File 'lib/fox16/execute_nonmodal.rb', line 55 def onCmdAccept(*args) # :nodoc: on_nonmodal_close(true) end |
#onCmdCancel(*args) ⇒ Object
:nodoc:
51 52 53 |
# File 'lib/fox16/execute_nonmodal.rb', line 51 def onCmdCancel(*args) # :nodoc: on_nonmodal_close(false) end |