Top Level Namespace

Defined Under Namespace

Modules: GladeGUI, VR

Instance Method Summary collapse

Instance Method Details

#alert(message, options = {}) ⇒ String, ...

The alert method creates a pop-up alert in your program. It creates a modal window that halts execution of your code until the user closes it. Its great for displaying messages and debugging. It also has the option of allowing the user input in the form of a String or a selection from a Hash or Array. This small tool can save hundreds of lines of code in your programs. It can be used extesnively to display all types of messages and request all types of user input.

The alert box can disply 1, 2 or 3 buttons. The first button is denoted using the symbol: :button_yes button and is always displayed. You can add :button_no and :button_cancel.

If you want to add these buttons, just set their values to whatever text you want them to display and they will appear. Likewise, if you pass a :data parameter with a String, Hash or Array, it will ask for user input.

There are many examples in the “alert_box” example project.

Examples:

alert("Continue?", button_no: "Nope", button_cancel: "Quit", parent: self) 
alert "The file you selected is already on disk.  Do you want to overwrite it?",
  headline: "Overwrite FIle?",
  button_yes: "Overwrite",
  button_no: "Reload From Disk",
  button_cancel: "Cancel"

Parameters:

  • message (String)

    text message to display in alert box. Uses markup.

  • options (Hash) (defaults to: {})

    Hash of options: :button_yes => text on the button that returns true.

Options Hash (options):

  • :button_yes (String)

    Text that appears on the “yes” button.

  • :button_no (String)

    Text that appears on “no” button. (set to make no button appear)

  • :button_cancel (String)

    Text that appears on “cancel” button. (set to make cancel button appear)

  • :data (Variable)

    Either String, Array, or Hash. This will determine type of user input.

  • :headline (String)

    Larger headline over text message.

  • :title (String)

    Title of the alert box window. Defaults to :headline.

  • :width (Integer)

    The width in pixels of the window. Used for wrapping text.

  • :parent (Object #builder)

    The window that the alert box is always on top of.

Returns:

  • (String)

    text in the text entry field when the :button_yes button is pressed. (:data passed a String)

  • (String)

    selected text from dropdown when the :button_yes button is pressed. (:data passed an Array)

  • (Hash)

    When :data is passed as Hash, this is updated Hash from user input.

  • (true)

    When the :button_yes button is selected and there’s no text entry box.

  • (false)

    When :button_no is pressed

  • (nil)

    When :button_cancel or the “X” button is pressed.



140
141
142
143
# File 'lib/AlertDialog.rb', line 140

def alert(message, options = {})
  win = VR::AlertDialog.new(message, options)
  return win.run()
end

#alert2(message, options = {}) ⇒ String, ...

The alert method creates a pop-up alert in your program. It creates a modal window that halts execution of your code until the user closes it. Its great for displaying messages and debugging. It also has the option of allowing the user input in the form of a String or a selection from a Hash or Array. This small tool can save hundreds of lines of code in your programs. It can be used extesnively to display all types of messages and request all types of user input.

The alert box can disply 1, 2 or 3 buttons. The first button is denoted using the symbol: :button_yes button and is always displayed. You can add :button_no and :button_cancel.

If you want to add these buttons, just set their values to whatever text you want them to display and they will appear. Likewise, if you pass a :data parameter with a String, Hash or Array, it will ask for user input.

There are many examples in the “alert_box” example project.

Examples:

alert("Continue?", button_no: "Nope", button_cancel: "Quit", parent: self) 
alert "The file you selected is already on disk.  Do you want to overwrite it?",
  headline: "Overwrite FIle?",
  button_yes: "Overwrite",
  button_no: "Reload From Disk",
  button_cancel: "Cancel"

Parameters:

  • message (String)

    text message to display in alert box. Uses markup.

  • options (Hash) (defaults to: {})

    Hash of options: :button_yes => text on the button that returns true.

Options Hash (options):

  • :button_yes (String)

    Text that appears on the “yes” button.

  • :button_no (String)

    Text that appears on “no” button. (set to make no button appear)

  • :button_cancel (String)

    Text that appears on “cancel” button. (set to make cancel button appear)

  • :data (Variable)

    Either String, Array, or Hash. This will determine type of user input.

  • :headline (String)

    Larger headline over text message.

  • :title (String)

    Title of the alert box window. Defaults to :headline.

  • :width (Integer)

    The width in pixels of the window. Used for wrapping text.

  • :parent (Object #builder)

    The window that the alert box is always on top of.

Returns:

  • (String)

    text in the text entry field when the :button_yes button is pressed. (:data passed a String)

  • (String)

    selected text from dropdown when the :button_yes button is pressed. (:data passed an Array)

  • (Hash)

    When :data is passed as Hash, this is updated Hash from user input.

  • (true)

    When the :button_yes button is selected and there’s no text entry box.

  • (false)

    When :button_no is pressed

  • (nil)

    When :button_cancel or the “X” button is pressed.



145
146
147
148
149
# File 'lib/Alert.rb', line 145

def alert2(message, options = {})
  ans = VR::Alert::DialogAnswer.new()
  VR::Alert.new(message, ans, options).show_glade(options[:parent])
  return ans.answer 
end

#oinspect(obj = self) ⇒ Object

Displays object on screen and halts the program. Anywhere in your code you can halt the execution, and display an object in a window like this:

oinspect anyobject

Also, at any window, if you press the F8 key, the object inspector will run. Try it.

Parameters:

  • obj (Object) (defaults to: self)

    Any object that you want to display.

Returns:

  • none.



42
43
44
# File 'lib/oinspect/ObjectInspectorGUI.rb', line 42

def oinspect(obj=self)
  VR::ObjectInspector::ObjectInspectorGUI.new(obj).show_glade()
end