Messagebox within a callback fails
-
Hi all,
I'm encountering this problem:
When writing a callback function, everything goes well until a messagebox call: the SU window suddenly minimizes to the taskbar
, the message box doesn't pops-up and the callback stops 
Something like this:
@web_dialog.add_action_callback("wcCreatePlace") { |d, p| # Possible opening ? pushPullDoable=validateFace4Pushpull(face) if pushPullDoable dist=findWallFaceDistance(face) if dist # EVERYTHING OK UNTIL HERE rep=UI.messagebox("Open the wall ?",MB_YESNO) face.pushpull(-dist) if rep == IDYES end end }Anyone encountered this before ?
-
@didier bur said:
Hi all,
I'm encountering this problem:
When writing a callback function, everything goes well until a messagebox call: the SU window suddenly minimizes to the taskbar
, the message box doesn't pops-up and the callback stops 
I don't have the problem, but I use a generic block for the call back and then dispatch the action.
Anyway, very strange!
In your code, I see a variable <face> that is not initialized in the block. Is this the real code?
-
Thanks Fredo,
No, that's not the real code, simplified for readability.
En fait, "face" est une variable d'instance @face dans mon vrai code, j'ai simplifié pour poster ici.
Je n'ai toujours pas solutionné le pb, j'ai mis des mouchards partout pour tracer ce que fait le callback, et dès que la messagebox est appelée, plus rien...
Je vais calquer ma manière de faire sur la tienne
-
Change this one line to output 'face' & 'dist' to the Ruby Console just before the failure.
**p face; p** dist=findWallFaceDistance(face) -
@TIG
Thanks for the hint, unfortunately it doesn't help, I'm getting the correct values for face and dist outputs. BUT, I tried to call message box in others callbacks, it worked in every case.
So what was wrong with this particular callback ? Guess what, one CANNOT call a UI.messagebox after a webdialog (or html dialog) closes, modal or non-modal.
There's some kind of logic here...This doesn't work:
# callback cancel @web_dialog.add_action_callback("dlg_cancel_settings") { |d, p| @web_dialog.close() r=UI.messagebox("Are you sure ?",MB_YESNO) }This works:
# callback cancel @web_dialog.add_action_callback("dlg_cancel_settings") { |d, p| r=UI.messagebox("Are you sure ?",MB_YESNO) @web_dialog.close() }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement