Class: TT::GUI::ModalWrapper
- Inherits:
-
Object
- Object
- TT::GUI::ModalWrapper
- Defined in:
- TT_Lib2/modal_wrapper.rb
Overview
TODO:
Prevent other Windows from opening (?)
Creates a wrapper class that simulates a modal environment for the window. It is not truly modal because of limitations of the API under OSX, but uses a tool class to prevent the user from manipulating the model while the window is open. If the user should activate another tool it acts as if the user used the Close or cancel button.
Constant Summary
- @@open_window =
nil
Instance Method Summary collapse
-
#close ⇒ Object
Closes the modal window.
-
#initialize(window) ⇒ ModalWrapper
constructor
A new instance of ModalWrapper.
-
#show ⇒ Object
Displays the modal window as long as there are no other modal windows open.
Constructor Details
#initialize(window) ⇒ ModalWrapper
Returns a new instance of ModalWrapper
28 29 30 |
# File 'TT_Lib2/modal_wrapper.rb', line 28 def initialize(window) @window = window end |
Instance Method Details
#close ⇒ Object
Closes the modal window.
118 119 120 121 122 123 124 125 126 127 |
# File 'TT_Lib2/modal_wrapper.rb', line 118 def close #puts 'T:close' #puts caller.join("\r\n") # Prevent popping the tool multiple times. This worked fine in older SketchUp # versions, but regressed in SU2014 where it would then cause a crash. return false if @closing @closing = true Sketchup.active_model.tools.pop_tool true end |
#show ⇒ Object
Displays the modal window as long as there are no other modal windows open.
It only handles TT::GUI::Window
objects that uses the
ModalWrapper
class.
104 105 106 107 108 109 110 111 112 113 |
# File 'TT_Lib2/modal_wrapper.rb', line 104 def show #puts 'T:show' @closing = false if @@open_window UI.beep @@open_window.bring_to_front else Sketchup.active_model.tools.push_tool( self ) end end |