sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Messagebox within a callback fails

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 6.5k Views 3 Watching
    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.
    • Didier BurD Offline
      Didier Bur
      last edited by

      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
      • fredo6F Offline
        fredo6
        last edited by

        @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
        • Didier BurD Offline
          Didier Bur
          last edited by

          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
          • TIGT Online
            TIG Moderator
            last edited by

            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
            • Didier BurD Offline
              Didier Bur
              last edited by

              @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
              • First post
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement