Class: AMS::SketchupObserver

Inherits:
Object
  • Object
show all
Defined in:
sketchup_observer.rb

Overview

Note:

SWO events are capable of monitoring window events. SWP events are capable of monitoring a making decisions to window events. Returning 1 in SWP event will prevent the event from interacting with SketchUp window procedure; any other return value won't block the event. If more than one observers install SWP events and one of them returns 1, then the event will be prevent, regardless of whether other observers wanted the event to be processed by SketchUp window procedure.

AMS SketchUp Observer allows you to monitor and make decisions to SketchUp window events.

Examples:

Processing keyboard events:

class MySketchupObserver

  def swp_on_key_down(vk_name, vk_value, vk_char)
    puts "on_key_down: #{vk_name}"
    # ...
    # Returning 1 will prevent current pressed key from interacting with SU
    # window procedure.
    # Here, we'll return 1 to W,S,A,D keys, so we could use them for our own
    # purpose, rather than having shortcuts changing the tool.
    return %(w s a d).include?(vk_name) ? 1 : 0
  end

  def swp_on_key_extended(vk_name, vk_value, vk_char)
    puts "on_key_extended: #{vk_name}"
    # ...
    # If you return 1 for the on_key_down event, it's also preferred to
    # return 1 for the on_key_extended event, so the key doesn't stand a
    # chance to interact with SketchUp window procedure.
    return %(w s a d).include?(vk_name) ? 1 : 0
  end

  def swp_on_key_up(vk_name, vk_value, vk_char)
    puts "on_key_up: #{vk_name}"
    # ...
    # If you return 1 for the on_key_down event, it's also preferred to
    # return 1 for the on_key_up event, so the key doesn't stand a chance to
    # interact with SketchUp window procedure.
    return %(w s a d).include?(vk_name) ? 1 : 0
  end

end # class MySketchupObserver

AMS::Sketchup.add_observer(MySketchupObserver.new)

See Also:

Observer Events (collapse)

Mouse Input Events (collapse)

Keybaord Input Events (collapse)

SketchUp Window Events (collapse)

Instance Method Details

- (Object) swo_activate

Called whenever the observer is added.

Since:

  • 2.0.0



51
52
# File 'sketchup_observer.rb', line 51

def swo_activate
end

- (Object) swo_deactivate

Called whenever the observer is removed.

Since:

  • 2.0.0



56
57
# File 'sketchup_observer.rb', line 56

def swo_deactivate
end

- (Object) swo_error(e)

Note:

An error will not force the observer to deactivate. If you want the observer to deactivate on error, then this is the event to be implemented.

Note:

If this event is not implemented, by default, the error will be outputted in console.

Note:

If there is an error in this event, the error message will be outputted in console.

Triggered whenever there is an error in any observer events, except this one.

Parameters:

  • e (Exception)

Since:

  • 2.0.0



69
70
# File 'sketchup_observer.rb', line 69

def swo_error(e)
end

- (Object) swo_on_blur

Called when main window is deactivated.

Since:

  • 2.0.0



321
322
# File 'sketchup_observer.rb', line 321

def swo_on_blur
end

- (Object) swo_on_caption_changed(text)

Called when main window title text is changed.

Parameters:

  • text (String)

    New text

Since:

  • 2.0.0



350
351
# File 'sketchup_observer.rb', line 350

def swo_on_caption_changed(text)
end

- (Object) swo_on_enter_menu

Called when the application enters the menu loop.

Since:

  • 2.0.0



284
285
# File 'sketchup_observer.rb', line 284

def swo_on_enter_menu
end

- (Object) swo_on_enter_size_move(x, y, w, h)

Called when main window enters the state of being sized and/or moved.

Parameters:

  • x (Fixnum)

    X coordinate of window origin, relative to the upper-left corner of the screen.

  • y (Fixnum)

    Y coordinate of window origin, relative to the upper-left corner of the screen.

  • w (Fixnum)

    Window width in pixels.

  • h (Fixnum)

    Window height in pixels.

Since:

  • 2.0.0



332
333
# File 'sketchup_observer.rb', line 332

def swo_on_enter_size_move(x,y, w,h)
end

- (Object) swo_on_exit_menu

Called when the application exits the menu loop.

Since:

  • 2.0.0



289
290
# File 'sketchup_observer.rb', line 289

def swo_on_exit_menu
end

- (Object) swo_on_exit_size_move(x, y, w, h)

Called when main window exits the state of being sized and/or moved.

Parameters:

  • x (Fixnum)

    X coordinate of window origin, relative to the upper-left corner of the screen.

  • y (Fixnum)

    Y coordinate of window origin, relative to the upper-left corner of the screen.

  • w (Fixnum)

    Window width in pixels.

  • h (Fixnum)

    Window height in pixels.

Since:

  • 2.0.0



344
345
# File 'sketchup_observer.rb', line 344

def swo_on_exit_size_move(x,y, w,h)
end

- (Object) swo_on_focus

Called when main window is activated.

Since:

  • 2.0.0



316
317
# File 'sketchup_observer.rb', line 316

def swo_on_focus
end

- (Object) swo_on_maximize

Called when main window is maximized.

Since:

  • 2.0.0



301
302
# File 'sketchup_observer.rb', line 301

def swo_on_maximize
end

- (Object) swo_on_menu_bar_changed(state)

Called when main window menu bar is set or removed.

Parameters:

  • state (Boolean)

    A true value indicates the menu bar is set; a false value indicates the menu bar is removed.

Since:

  • 2.0.0



357
358
# File 'sketchup_observer.rb', line 357

def swo_on_menu_bar_changed(state)
end

- (Object) swo_on_minimize

Called when main window is minimized.

Since:

  • 2.0.0



306
307
# File 'sketchup_observer.rb', line 306

def swo_on_minimize
end

- (Object) swo_on_mouse_enter(x, y)

Called when cursor enters the viewport client area.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Since:

  • 2.0.0



213
214
# File 'sketchup_observer.rb', line 213

def swo_on_mouse_enter(x,y)
end

- (Object) swo_on_mouse_leave(x, y)

Called when cursor leaves the viewport client area.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Since:

  • 2.0.0



219
220
# File 'sketchup_observer.rb', line 219

def swo_on_mouse_leave(x,y)
end

- (Object) swo_on_mouse_move(x, y)

Called when cursor is moved within the viewport client area.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Since:

  • 2.0.0



225
226
# File 'sketchup_observer.rb', line 225

def swo_on_mouse_move(x,y)
end

- (Object) swo_on_quit

Called right before SketchUp window is destroyed.

Since:

  • 2.0.0



279
280
# File 'sketchup_observer.rb', line 279

def swo_on_quit
end

- (Object) swo_on_restore

Called when main window is set to normal placement.

Since:

  • 2.0.0



311
312
# File 'sketchup_observer.rb', line 311

def swo_on_restore
end

- (Object) swo_on_scenes_bar_emptied

Called when scenes bar loses its last page.

Since:

  • 2.0.0



394
395
# File 'sketchup_observer.rb', line 394

def swo_on_scenes_bar_emptied
end

- (Object) swo_on_scenes_bar_filled

Called when scenes bar gets its first page.

Since:

  • 2.0.0



389
390
# File 'sketchup_observer.rb', line 389

def swo_on_scenes_bar_filled
end

- (Object) swo_on_scenes_bar_visibility_changed(state)

Called when scenes bar is shown or hidden.

Parameters:

  • state (Boolean)

    A true value indicates scenes bar is set visible; a false value indicates scenes bar is set hidden.

Since:

  • 2.0.0



384
385
# File 'sketchup_observer.rb', line 384

def swo_on_scenes_bar_visibility_changed(state)
end

- (Object) swo_on_size_move(x, y, w, h)

Called when main window is being sized and/or moved.

Parameters:

  • x (Fixnum)

    X coordinate of window origin, relative to the upper-left corner of the screen.

  • y (Fixnum)

    Y coordinate of window origin, relative to the upper-left corner of the screen.

  • w (Fixnum)

    Window width in pixels.

  • h (Fixnum)

    Window height in pixels.

Since:

  • 2.0.0



338
339
# File 'sketchup_observer.rb', line 338

def swo_on_size_move(x,y, w,h)
end

- (Object) swo_on_status_bar_visibility_changed(state)

Called when status bar is shown or hidden.

Parameters:

  • state (Boolean)

    A true value indicates status bar is set visible; a false value indicates status bar is set hidden.

Since:

  • 2.0.0



401
402
# File 'sketchup_observer.rb', line 401

def swo_on_status_bar_visibility_changed(state)
end

- (Object) swo_on_switch_full_screen(state)

Called when main window full screen state is changed.

Parameters:

  • state (Boolean)

    A true value indicates the window is set full screen. A false value indicates the window was set to original placement.

Since:

  • 2.0.0



296
297
# File 'sketchup_observer.rb', line 296

def swo_on_switch_full_screen(state)
end

- (Object) swo_on_toolbar_container_emptied(bar)

Called when toolbar container is emptied.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right.

Since:

  • 2.0.0



421
422
# File 'sketchup_observer.rb', line 421

def swo_on_toolbar_container_emptied(bar)
end

- (Object) swo_on_toolbar_container_filled(bar)

Called when toolbar container is filled.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right.

Since:

  • 2.0.0



415
416
# File 'sketchup_observer.rb', line 415

def swo_on_toolbar_container_filled(bar)
end

- (Object) swo_on_toolbar_container_visibility_changed(bar, state)

Called when toolbar container is shown or hidden.

Parameters:

  • bar (Fixnum)

    1 - top, 2 - bottom, 3 - left, 4 - right.

  • state (Boolean)

    A true value indicates toolbar container is set visible; a false value indicates toolbar container is set hidden.

Since:

  • 2.0.0



409
410
# File 'sketchup_observer.rb', line 409

def swo_on_toolbar_container_visibility_changed(bar, state)
end

- (Object) swo_on_viewport_border_changed(state)

Called when view border, a thin edge surrounding the view, is set or removed.

Parameters:

  • state (Boolean)

    A true value indicates the edge is set; a false value indicates the edge is removed.

Since:

  • 2.0.0



377
378
# File 'sketchup_observer.rb', line 377

def swo_on_viewport_border_changed(state)
end

- (Object) swo_on_viewport_paint

Called when the view window is redrawn.

Since:

  • 2.0.0



362
363
# File 'sketchup_observer.rb', line 362

def swo_on_viewport_paint
end

- (Object) swo_on_viewport_size(w, h)

Called when the view window is sized.

Parameters:

  • w (Fixnum)

    View width in pixels.

  • h (Fixnum)

    View height in pixels.

Since:

  • 2.0.0



369
370
# File 'sketchup_observer.rb', line 369

def swo_on_viewport_size(w,h)
end

- (Fixnum) swp_on_command(id)

Called when SketchUp window procedure comes across the WM_COMMAND message. This event responds to Sketchup.send_action, as it too, generates WM_COMMAND messages.

Parameters:

  • id (Fixnum)

    Command identifier

Returns:

  • (Fixnum)

    A return value of 1 will prevent the command from reaching SketchUp window procedure; any other return value won't block the command.

Since:

  • 2.0.0



274
275
# File 'sketchup_observer.rb', line 274

def swp_on_command(id)
end

- (Fixnum) swp_on_key_down(vk_name, vk_value, vk_char)

Called when key is pressed.

Parameters:

  • vk_name (String)

    Virtual key name

  • vk_value (Fixnum)

    Virtual key constant value

  • vk_char (String)

    Actual key character

Returns:

  • (Fixnum)

    A return value of 1 will prevent the key from interacting with SketchUp window procedure; any other return value will not block the key.

Since:

  • 2.0.0



239
240
# File 'sketchup_observer.rb', line 239

def swp_on_key_down(vk_name, vk_value, vk_char)
end

- (Fixnum) swp_on_key_extended(vk_name, vk_value, vk_char)

Called when key is held down.

Parameters:

  • vk_name (String)

    Virtual key name

  • vk_value (Fixnum)

    Virtual key constant value

  • vk_char (String)

    Actual key character

Returns:

  • (Fixnum)

    A return value of 1 will prevent the key from interacting with SketchUp window procedure; any other return value will not block the key.

Since:

  • 2.0.0



250
251
# File 'sketchup_observer.rb', line 250

def swp_on_key_extended(vk_name, vk_value, vk_char)
end

- (Fixnum) swp_on_key_up(vk_name, vk_value, vk_char)

Called when key is released.

Parameters:

  • vk_name (String)

    Virtual key name

  • vk_value (Fixnum)

    Virtual key constant value

  • vk_char (String)

    Actual key character

Returns:

  • (Fixnum)

    A return value of 1 will prevent the key from interacting with SketchUp window procedure; any other return value will not block the key.

Since:

  • 2.0.0



261
262
# File 'sketchup_observer.rb', line 261

def swp_on_key_up(vk_name, vk_value, vk_char)
end

- (Fixnum) swp_on_lbutton_double_click(x, y)

Called when left mouse button is double clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



98
99
# File 'sketchup_observer.rb', line 98

def swp_on_lbutton_double_click(x,y)
end

- (Fixnum) swp_on_lbutton_down(x, y)

Called when left mouse button is clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



84
85
# File 'sketchup_observer.rb', line 84

def swp_on_lbutton_down(x,y)
end

- (Fixnum) swp_on_lbutton_up(x, y)

Called when left mouse button is released.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



91
92
# File 'sketchup_observer.rb', line 91

def swp_on_lbutton_up(x,y)
end

- (Fixnum) swp_on_mbutton_double_click(x, y)

Called when middle mouse button is double clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



119
120
# File 'sketchup_observer.rb', line 119

def swp_on_mbutton_double_click(x,y)
end

- (Fixnum) swp_on_mbutton_down(x, y)

Called when middle mouse button is clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



126
127
# File 'sketchup_observer.rb', line 126

def swp_on_mbutton_down(x,y)
end

- (Fixnum) swp_on_mbutton_up(x, y)

Called when middle mouse button is released.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



133
134
# File 'sketchup_observer.rb', line 133

def swp_on_mbutton_up(x,y)
end

- (Fixnum) swp_on_mouse_wheel_rotate(x, y, dir)

Called when mouse wheel is rotated.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

  • dir (Fixnum)

    A positive value (1) indicates that the wheel was rotated forward, away from the user; a negative value (-1) indicates that the wheel was rotated backward, toward the user.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



195
196
# File 'sketchup_observer.rb', line 195

def swp_on_mouse_wheel_rotate(x,y, dir)
end

- (Fixnum) swp_on_mouse_wheel_tilt(x, y, dir)

Called when mouse wheel is tilted.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

  • dir (Fixnum)

    A positive value (1) indicates that the wheel was tilted right; a negative value (-1) indicates that the wheel was tilted left.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



207
208
# File 'sketchup_observer.rb', line 207

def swp_on_mouse_wheel_tilt(x,y, dir)
end

- (Fixnum) swp_on_rbutton_down(x, y)

Called when right mouse button is clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



105
106
# File 'sketchup_observer.rb', line 105

def swp_on_rbutton_down(x,y)
end

- (Fixnum) swp_on_rbutton_up(x, y)

Called when right mouse button is released.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



112
113
# File 'sketchup_observer.rb', line 112

def swp_on_rbutton_up(x,y)
end

- (Fixnum) swp_on_xbutton1_double_click(x, y)

Called when X mouse button 1 is double clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



161
162
# File 'sketchup_observer.rb', line 161

def swp_on_xbutton1_double_click(x,y)
end

- (Fixnum) swp_on_xbutton1_down(x, y)

Called when X mouse button 1 is clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



147
148
# File 'sketchup_observer.rb', line 147

def swp_on_xbutton1_down(x,y)
end

- (Fixnum) swp_on_xbutton1_up(x, y)

Called when X mouse button 1 is released.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



154
155
# File 'sketchup_observer.rb', line 154

def swp_on_xbutton1_up(x,y)
end

- (Fixnum) swp_on_xbutton2_double_click(x, y)

Called when X mouse button 2 is double clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



182
183
# File 'sketchup_observer.rb', line 182

def swp_on_xbutton2_double_click(x,y)
end

- (Fixnum) swp_on_xbutton2_down(x, y)

Called when X mouse button 2 is clicked.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



168
169
# File 'sketchup_observer.rb', line 168

def swp_on_xbutton2_down(x,y)
end

- (Fixnum) swp_on_xbutton2_up(x, y)

Called when X mouse button 2 is released.

Parameters:

  • x (Fixnum)

    X cursor position relative to the upper-left corner of the viewport client area.

  • y (Fixnum)

    Y cursor position relative to the upper-left corner of the viewport client area.

Returns:

  • (Fixnum)

    A return value of 1 will prevent this event from interacting with SketchUp window procedure. Any other return value will allow this event to interact with SketchUp window procedure.

Since:

  • 2.0.0



175
176
# File 'sketchup_observer.rb', line 175

def swp_on_xbutton2_up(x,y)
end