messagebox within a callback fails

messagebox within a callback fails

Postby Didier Bur » Sun Mar 31, 2019 11:28 am

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 :shock:

Something like this:
Code: Select all
@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 ?
0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: messagebox within a callback fails

Postby fredo6 » Mon Apr 01, 2019 7:49 pm

Didier Bur wrote: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 :shock:

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?
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: messagebox within a callback fails

Postby Didier Bur » Tue Apr 02, 2019 2:17 pm

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 ;-)
0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: messagebox within a callback fails

Postby TIG » Tue Apr 02, 2019 2:50 pm

Change this one line to output 'face' & 'dist' to the Ruby Console just before the failure.
p face; p dist=findWallFaceDistance(face)
0
TIG
User avatar
TIG 
Global Moderator
 

Re: messagebox within a callback fails

Postby Didier Bur » Wed Apr 03, 2019 8:34 am

@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:
Code: Select all
# 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:
Code: Select all
# callback cancel
@web_dialog.add_action_callback("dlg_cancel_settings") { |d, p|
   r=UI.messagebox("Are you sure ?",MB_YESNO)
   @web_dialog.close()
}
0
Didier Bur
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: Alethéa and 9 guests

Visit our sponsors: