Class: TT::GUI::ModalWrapper

Inherits:
Object
  • Object
show all
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.

Since:

  • 2.4.0

Constant Summary

@@open_window =

Since:

  • 2.4.0

nil

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ ModalWrapper

Returns a new instance of ModalWrapper

Parameters:

Since:

  • 2.4.0



28
29
30
# File 'TT_Lib2/modal_wrapper.rb', line 28

def initialize(window)
  @window = window
end

Instance Method Details

#closeObject

Closes the modal window.

Since:

  • 2.4.0



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

#showObject

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.

Since:

  • 2.4.0



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