Dan Rathbun
unread,Sep 14, 2011, 2:06:09 PM9/14/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google SketchUp Developers - SketchUp Ruby API
Well Joe..
Basically suspend() might call view.invalidate() to get rid of any
graphics you've drawn on the view, and possibly be sure to save the
state of the tool, temporary points, etc.
When resume() is called, you put the tool back into the state it was
when it was suspended. Say the user had picked a point that is stored
in @pt1, and your @state var == 1 (0 when the tool is first activated,
and before the user picks the start point.)
You then need to redraw the view line again (usually by manually
calling the onMouseMove callback and passing the @pt1 as an argument.)
Or perhaps you have defined a private method that advances the tool
through each state, then you just call that on resume()
def resume(view)
set_state(@state,view)
end
private
def set_state(state,view)
if state==0
# do stuff
@state = @state.next
elsif state==1
# do stuff
@state = @state.next
elsif state==2
# do stuff
@state = @state.next
else
# do final stuff
# now reset tool which should set @state to 0
reset()
end
end
I am surprised that the Google "linetool.rb" example did not show
these callbacks. The example should be updated.