Open voqhai opened 3 years ago
With the other events we get the mouse coordinates from the underlying OS mouse events.
In this case, activate
is not a mouse event, so it poses additional challenges. It would be possible to compute the X, Y, but then you have the case of the mouse might not even be within the viewport - which isn't unlikely if the tool was activated via a menu or toolbar button.
Can you elaborate on how you'd deal with that in your extension? Can you explain more about your higher level goals here?
If the mouse outside the viewport when activate
, I think the value of x, y should be nil
, so I will choose to draw(view)
or dialog.show
at the center or edge of the viewport
@voqhai : If the mouse outside the viewport when
activate
, I think the value of x, y should benil
, ...
I would think it better to follow precedent set by the View#screen_coords
method, ... ie:
If the referenced point is not in the current viewport, the x and/or y value may be negative.
... and speaking of the View#screen_coords
method, ...
@thomthom, perhaps the easiest solution might be to create an override for the absence of an argument which would return the screen coordinates of the current mouse position when the method is called.
In this way the tool activate
callback wouldn't be compromised with "out of band" behavior.
When Tool activates, I want to know the current mouse position to draw something at the cursor or display a dialog nearby. I don't want the user to have to click or move mouse to get the position.
https://ruby.sketchup.com/Sketchup/Tool.html#activate-instance_method
``