sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    UI Messagebox within LMB method of a tool

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 1.0k Views 2 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.
    • T Offline
      tomasz
      last edited by

      vI have no idea how to make messagebox 😒 displayed within create method of a tool.
      It is working but it is not visible. Sad I am afraid there is no solution.

      Thanks
      Tomasz

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomasz
        last edited by

        I have found solution. I had to move UI.messagebox to draw method.
        If you display UI.messagebox in draw method it will be invoked twice
        if not suppressed earlier

        
        if displayed==false
        displayed=true #to prevent second execution of whole if-end section
        UI.messagebox "Hello world!"
        displayed=false
        end
        

        Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by

          The .draw method is called every time you execute the view.invalidate method. Therefore, you control when the screen gets updated.

          I know of no restrictions that UI.messagebox can only be placed in the .draw method. It can be placed anywhere. (I just tested it to confirm in both the onLeftButtonDown and initialize method).

          Todd

          1 Reply Last reply Reply Quote 0
          • T Offline
            tomasz
            last edited by

            Draw method is also executed when you open Messagebox within the method πŸ˜„.

            I have placed UI.mb in LMB method and it was not displayed. It was invisible but present, awaiting for user input. I cannot validate the view during UI.mb. Todd how have you achieved it? πŸ˜„
            I am still new to Tools methods so I could have done sth wrong.

            Tomasz

            Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              Can you post your code? It works great for me in the onLButtonDown method, both before and after the view.invalidate call.

              Todd

              If you don't want to post, send it to my fullname, no spaces, to my mac dot com address.

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomasz
                last edited by

                I have found it! Silly me. I have placed view.invalidate at the end of draw method 😳

                def draw(view)
                
                	if( @ip1.valid? )
                		if( @ip1.display? )
                			@ip1.draw(view)
                			@drawn = true
                		end
                	end
                	if( @ip2.valid? )
                		@ip2.draw(view) if( @ip2.display?)
                		self.draw_geometry(@ip1.position, @ip2.position, view)
                		view.invalidate #WRONG!
                		@drawn = true
                	end
                end
                

                Each time UI.messagebox was invoked SU called draw method which erased MB from the view.
                Thanks
                Tomasz

                Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                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