Auto close UI.messagebox (Bug or feature?)
-
Hi All,
I did not find "official" method to automatically close messagebox. However when I tried to find some similar accidentally i find out this:
(Paste it to your console.)wd = UI;;WebDialog.new("Dialog", true, "W1", 800,800,100,100,true) wd.set_html("This window will close automaticaly after 5 sec...") id = UI.start_timer(5, false) { wd.close;UI.beep } wd.show UI.messagebox('Do not click OK!...SketchUp will close this too')
Btw: if you size the webdialog smaller than messagebox it is looks like you ara using only messagebox. (Since SU will put the messagebox same place as wd.)
Is that a known feature or bug?
-
@dezmo said:
Is that a known feature or bug?
That is a definite bug. No programmer in their right mind would purposely set that up to work that way.
-
That's very strange... not sure what is going on there. Bug for sure.
-
BTW: UI.messagebox must be clicked to close on a mac, as expected...
john
-
On Windows, the native messagebox window objects can be set to autoclose, as the function has a timeout argument. But the SU API never leveraged this feature.
Trying to use WScript shell object's messagebox interface from SketchUp Ruby to have auto-close message box windows is a failure. What happens is the windows are on top of the Z order, but non-modal. Ie the user can use the SketchUp interface whilst the messagebox remains open. This shouldn't really occur.
Wrapping the code in a
UI.start_timer
just makes things weirder and weirder. I did get them to auto-close but, the amount of time they are open is pseudo-random (depending on what happens in the background.) IE, if I tell it to stay open 3 seconds, it will be open somewhere between 5..10 seconds.I gave up after a few days of wasted effort.
-
I hope it will be corrected sometime..and real autoclose (or close from code) will implemented for messagebox.
-
@dezmo said:
I hope it will be corrected sometime..and real autoclose (or close from code) will implemented for messagebox.
What would the use case for that be?
-
@thomthom said:
What would the use case for that be?
If you know in advance that there will be long operation, you can prepare a message box which will come after e.g. 5-10 min. " It seems to much time to process, do you want to abort or go ahead?"
The UI:messagebox is suspending the operation and the code is continuing if it is closed. (At least in windows...)
But if the user is not responding for e.g. 30-60sec the message box will close automaticly and the code is continuing to process.You can't use webdialog, because in long operation SU (including WD) is not responding at all.
For sure there is other workaround, or possible to do your code on other way, but this could be an "easy" solution...
(I'm just an amateur engineer, not a programmer ... )
Advertisement