• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Messagebox within a callback fails

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 6.5k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    Didier Bur
    last edited by 31 Mar 2019, 10:28

    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 ?

    DB

    1 Reply Last reply Reply Quote 0
    • F Offline
      fredo6
      last edited by 1 Apr 2019, 18:49

      @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?

      1 Reply Last reply Reply Quote 0
      • D Offline
        Didier Bur
        last edited by 2 Apr 2019, 13:17

        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 😉

        DB

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 2 Apr 2019, 13:50

          Change this one line to output 'face' & 'dist' to the Ruby Console just before the failure.
          **p face; p** dist=findWallFaceDistance(face)

          TIG

          1 Reply Last reply Reply Quote 0
          • D Offline
            Didier Bur
            last edited by 3 Apr 2019, 07:34

            @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()
            }
            

            DB

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              5/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement