sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    [code] Menu Validation (MF_DISABLED bugged on PC?)

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 2 Posters 2.8k 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.
    • thomthomT Offline
      thomthom
      last edited by

      This is what I always use for validation procs:

      
        def self.can_paste_proc
          if self.can_paste?
            MF_ENABLED
          else
            MF_DISABLED | MF_GRAYED
          end
        end
      
      

      I though MF_DISABLED prevented the action from triggering. And that MF_GRAYED where used only for the visual effect.

      Thomas Thomassen β€” SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        hmm... testing in SU8M1, you're right. MF_DISABLED seem to do nothing. Only MF_GRAYED seems to affect anything.
        Though I imagine there is a reason I use MF_DISABLED | MF_GRAYED - just can't remember why. Can't find any notes on it.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          Same behaviour on SU6, 7.1 Windows.

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @thomthom said:

            Though I imagine there is a reason I use MF_DISABLED | MF_GRAYED - just can't remember why. Can't find any notes on it.

            I'll bet it's a cross-platform thangie... it does not seem to matter to Windows if the DISABLED bit is set, so no harm is done.

            Need a Mac guy to test it and let us know.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @thomthom said:

              This is what I always use for validation procs:

              Just being clear that the methods above are not the actual validation_proc. I try not to put conditional evaluations into the menu or toolbar procs, if I can do the decision in another place in the code. In most cases, the validation state does not change until the user actually clicks on the item (or button,) so it's better to change the menu item's (or button's) valid state within the command proc, or some other method that gets called. So when the change is made I just change the value of a @@validation class var (or @validation instance var,) and let Sketchup just pick up the value of that var when it must do a UI draw.

              So creating a menu item, would look like:
              item = menu.add_item('Some Menu Label') { ..execute_code.. } menu.set_validation_proc(item) { @@validation }

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Yea, that'd probably be better.

                IN my case I'd need an observer, but it'd still be more efficient.

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  Tested on OSX SU8.0M1 - Same behaviour, MF_DISABLED does nothing.

                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @thomthom said:

                    hmm... testing in SU8M1, you're right. MF_DISABLED seem to do nothing. Only MF_GRAYED seems to affect anything.

                    @thomthom said:

                    Same behaviour on SU6, 7.1 Windows.

                    @thomthom said:

                    Tested on OSX SU8.0M1 - Same behaviour, MF_DISABLED does nothing.

                    Thanks go to ThomThom for filing a Google BugReport on this, 30 JAN 2011. ❗

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      I still wonder why I've been using MF_DISABLED... πŸ˜•

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        Covering your butt.. just in case the API changes in the future?

                        I'm not here much anymore.

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by

                          Possibly. Maybe it was in another language where you had to gray and disable. ...Visual Basic...? Can't think of anything else where I've dealt with menus...

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          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