UI.messagebox
-
In the middle of testing out a new plugin I was creating, the UI.messagebox stopped displaying. The command was being executed because I could hear the beep and the plugin would lock up until I pressed Enter. I added a UI.messagebox command in a reset method that is executed when plugin starts and that one displayed as expected but no other messageboxes after that.
-
Well one rule.. don't put
UI.messagebox
calls insideUI.start_timer
blocks.You can have the console open when loading the plugin, and use
puts("string")
statements instead of messageboxes. -
I have also found that if you have an error in the messagebox string argument... the
UI.messagebox
call silently fails.Copy the argument for the messagebox to the console and press enter.. see if you get errors.
Second.. use
puts
and have the console open when loading... if there's an error in the arg.. then Ruby should spit out an Exception message.So rule 2: What works or doesn't for
puts
, will or won't forUI.messagebox
-
I don't have any UI.start_timer blocks so that can't be the problem. I did copy the entire code statement "UI.messagebox("There are no valid snap points", MB_OK)" to the console and the message displayed normally. I even added a UI.inputbox statement to see if it would display and, like messagebox, the tone sounded but nothing displayed. Other than a method that does a calculation, I can't think of anything in this plugin that I have used many times before.
-
Can you call the plugin's method(s) from the console, and see if you get any errors ?
-
@sdmitch said:
Other than a method that does a calculation, I can't think of anything in this plugin that I have used many times before.
That's likely it then.
I had a similar problem with a messagebox silently failing.
The error was a math calculation error, but not an exception. In other words Ruby was happy with the result, but the answer was a different class than I expected. (I wanted a float, but was getting a rounded integer, or visa versa.)The algorythm was my
path_knife()
method, for displaying long absolute path strings in a messagebox.
See this post for the method: [code] Split a long pathstring ~in half at the nearest '/'
Anyway whenever there's an error, the messagebox would not display.Did you know that you that you can use
rescue
as a modifier ? (Good to use, when wrapping the whole block in abegin .. rescue .. end
block is overkill.)var = 2 1.0/var
0.5
var = nil 1.0/var
Error: #<TypeError: (eval):414:in `/': nil can't be coerced into Float>
var = nil 1.0/var rescue 0.5
0.5
.
-
Dan, It turned out to be an unneeded View.invalidate statement.
Once it was removed, all was OK. -
Something similar occurs if you close dialog in a callback:
my_dialog.add_action_callback("test") do |web_dialog,param| web_dialog.close UI.messagebox('NOT DISPLAYED') end
-
@juantxo said:
Something similar occurs if you close dialog in a callback:
On the PC, this might work:
my_dialog.add_action_callback("test") do |web_dialog,param| web_dialog.close end my_dialog.set_on_close { UI.messagebox('NOT DISPLAYED') }
AFIAK,
set_on_close
is still bugged on the Mac
Advertisement