Some menus don't open during a custom tool operation
-
I am writing a construction line tool as an exercice. It is getting far more complex than the linetool.rb. Everything is fine but some menus (the Preference menu and all sub-menus) just don't open during the tool operation and the File/Exit simply do nothing. I have to select another tool or press the ALT key to have access to the menus or close Sketchup.
Besides, I observed that onMouseMove is not called when I press the ALT key. Specifically when the key goes up. The normal behavior returns after another ALT key press. The tool onKeyDown doesn't catch the ALT key, just the CTRL key and the TAB key.
The code is too large to display here.
Any ideas of the possible causes?
-
The ALT key giving focus to the menu, is a Windows system feature.
-
@roschetch said:
... but some menus (the Preference menu and all sub-menus) just don't open during the tool operation...
Preferences is a modal dialog box, not a menu.
-
I tested some good Ruby Tools and do not have any of the issues you describe in SketchUp 2014.
No problem accessing the menus, nor opening modal dialogs like Preferences.
The tools just resume after the dialog is closed, etc.Are you really still using version 8 Free ?
Suggest you do not use the ALT key within the tool.
-
Thank you, Dan, for your help.
Yes, I am using SU 8. And the tool do not use the ALT key, only CTRL , TAB and ESC.
With the tool active, I have access to all main menus (File, Edit, View, etc). But no submenu (like Edit/Unhide) open neither do the Preference modal dialog nor the Help/About. After trying to open the Preferences dialog, all main menu itens turn gray and the icons do not respond; the only ways I found to regain control of SU is either pressing the ALT key, the ESC key or a keyboard shortcut of another tool. After pressing the ALT key and closing the dialog, the tool resumes normally.
-
Disable ALL OTHER plugins when testing your Tool. To eliminate the possibility that some other plugin's
ToolsObserver
is not causing issues. -
Sorry, Dan, but no success. I removed all other tools from the plugin folder and disabled all the native SU tools. The odd behavior remains.
-
Ok then if your tool is the only thing loaded, then it is your code.
-
Dan, you are right and I think I found the bug source inside my own code.
I deleted the tool method codes leaving just the codes of activate, onMouseMove and draw. The bug remained active. So I stripped those codes to a minimum and then deleted one statement at a time. And I found an improper view.invalidate inside the draw code...
I am ashamed of this so basic mistake. I cannot remember why and when I put that line but it was there and caused the bug. I suppose that view.invalidate will, at some instance, call draw, right?
Thank you very much for your help.
-
Yes I think it does. Thomas can confirm.
-
Yes, view.invalidate will tell SketchUp to redraw. It doesn't redraw immediately, but let SketchUp manage update rate. Not sure how this is related to dialogs, focus and ALT key though...
Advertisement