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

    Flags for onMouseMove

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 3 Posters 1.4k 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.
    • fredo6F Offline
      fredo6
      last edited by fredo6

      On Windows, the flags for Buttondown in the event onMouseMove is 1. So the test flags & 1 == 1 tells whether the button is down.

      Just to be sure, is it the same on Mac?

      Fredo

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by

        does this help?

        onMouseMove; flags = 256
        onLButtonDown; flags = 258
        onLButtonUp; flags = 256
        onRButtonDown; flags = 264
        onRButtonUp; flags = 256
        onRButtonDown; flags = 264
        onMouseMove; flags = 264
        # misses the up but changes to move flag
        onMouseMove; flags = 256
        onRButtonDown; flags = 264
        onRButtonUp; flags = 256
        onMouseMove; flags = 256
        onMouseMove; flags = 256
        onLButtonDown; flags = 258
        onLButtonUp; flags = 256
        onMouseMove; flags = 256
        onLButtonDown; flags = 258
        onLButtonUp; flags = 256
        

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • S Offline
          slbaumgartner
          last edited by

          On Mac the flags are a (undocumented in SU) bit-map. Experimentally, 10 (2 decimal) is left button, 1000 (8 decimal) is right button. It's never been clear to me what they meant you do to with a bit-map that isn't documented!

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            Actually, I need the value of flags, for the onMouseMove method when the Left button is down.

            Apparently nothing that has a bit value of 1.

            Fredo

            1 Reply Last reply Reply Quote 0
            • D Offline
              driven
              last edited by

              Fredo, the flags were in there, the flag is 258...

              
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 258  #left down starts here
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 258  #left down
              onMouseMove; flags = 256  #left down released here
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              onMouseMove; flags = 256
              Key Tool Deactivated.
              
              
              

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 Reply Last reply Reply Quote 0
              • fredo6F Offline
                fredo6
                last edited by

                Thanks very much

                On Windows, the bitmask logic for onMouseMove is:

                • Left button down -> 1 (i.e. flags & 1 == 1)
                • Shift down -> 4
                • Ctrl down -> 8
                • Alt down -> 32
                  This logic also applies to onLButtonDown (alwasy contains 1) and onLButtonUp

                On Mac, the bitmask logic seems different. The flags always include 256, and the button and modifiers are adding to that:

                • Left button down -> 2 (i.e. flags & 2 == 2)
                • Shift down -> ?
                • Ctrl down -> ?
                • Alt down -> ?

                John: would be kind to check what are the value of flags for the 3 modifiers. Also, check the flags on the methods onLButtonDown and onLButtonUp to see if they respect the logic too.

                Thanks

                Fred

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  hi Fredo it's not so straight forward...
                  there are two ways to get RButtonDown on a mac and I think they have different flags...
                  but every mouse in the house has one fault or another...
                  this one has a broken RButton...

                  I'll update when I fix or buy a new mouse...

                  Key Tool Activated.
                  256 = onMouseMove 
                  "LButtonDown"
                  258 = onMouseMove with onLButtonDown 
                  "LButtonUP"
                  onKeyDown; Key code; 262144 ( VK_CONTROL )
                  "RButtonDown"
                  262409 = onMouseMove with onRButtonDown using control LButton
                  onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                  264 = onMouseMove with onRButtonDown 
                  256 = onMouseMove 
                  onKeyDown; Key code; 524288 ( VK_ALT or VK_MENU )
                  "LButtonDown"
                  524578 = onMouseMove with onLButtonDown with modifier 
                  "LButtonUP"
                  524576 = onMouseMove with onRButtonDown using control LButton
                  onKeyUp  ; Key code; 524288 ( VK_ALT or VK_MENU )
                  onKeyDown; Key code; 1048576 ( VK_COMMAND )
                  "LButtonDown"
                  1048842 = onMouseMove with onLButtonDown with modifier 
                  onKeyDown; Key code; 262144 ( VK_CONTROL )
                  1310987 = onMouseMove with onLButtonDown with modifier 
                  onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                  1048842 = onMouseMove with onLButtonDown 
                  onKeyUp  ; Key code; 1048576 ( VK_COMMAND )
                  258 = onMouseMove with onLButtonDown 
                  "LButtonUP"
                  Key Tool Deactivated.
                  

                  learn from the mistakes of others, you may not live long enough to make them all yourself...

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    slbaumgartner
                    last edited by

                    Here's my output from a modified version of the event reporter John was using. It covers all the combinations of mouse moves with one or both buttons pressed as well as any of the four modifier keys. I added printout of the hex and decimal values of the flags because I find that easier to understand than trying to subtract the decimal values all the time.

                    Key Tool Activated.
                    
                    "MouseMove"
                    Flags;      256 (0X000100 = 0b000000000000000000000100000000)
                    
                    "LButtonDown"
                    "MouseMove"
                    Flags;      258 (0X000102 = 0b000000000000000000000100000010)
                    "LButtonUP"
                    
                    "RButtonDown"
                    "MouseMove"
                    Flags;      264 (0X000108 = 0b000000000000000000000100001000)
                    
                    "LButtonDown"
                    "RButtonDown"
                    "MouseMove"
                    Flags;      266 (0X00010A = 0b000000000000000000000100001010)
                    "LButtonUP"
                    
                    onKeyDown; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    "MouseMove"
                    Flags;   131328 (0X020100 = 0b000000000000100000000100000000)
                    onKeyUp  ; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 262144 ( VK_CONTROL )
                    "MouseMove"
                    Flags;   262401 (0X040101 = 0b000000000001000000000100000001)
                    onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                    
                    onKeyDown; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    "MouseMove"
                    Flags;   524576 (0X080120 = 0b000000000010000000000100100000)
                    onKeyUp  ; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    "MouseMove"
                    Flags;  1048840 (0X100108 = 0b000000000100000000000100001000)
                    onKeyUp  ; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    "LButtonDown"
                    "MouseMove"
                    Flags;   131330 (0X020102 = 0b000000000000100000000100000010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 262144 ( VK_CONTROL )
                    "RButtonDown"
                    "MouseMove"
                    Flags;   262409 (0X040109 = 0b000000000001000000000100001001)
                    onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                    
                    onKeyDown; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    "LButtonDown"
                    "MouseMove"
                    Flags;   524586 (0X08012A = 0b000000000010000000000100101010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    "LButtonDown"
                    "MouseMove"
                    Flags;  1048842 (0X10010A = 0b000000000100000000000100001010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    "RButtonDown"
                    "MouseMove"
                    Flags;   131336 (0X020108 = 0b000000000000100000000100001000)
                    onKeyUp  ; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 262144 ( VK_CONTROL )
                    "RButtonDown"
                    "MouseMove"
                    Flags;   262409 (0X040109 = 0b000000000001000000000100001001)
                    onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                    
                    onKeyDown; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    "RButtonDown"
                    "MouseMove"
                    Flags;   524584 (0X080128 = 0b000000000010000000000100101000)
                    onKeyUp  ; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    "RButtonDown"
                    "MouseMove"
                    Flags;  1048840 (0X100108 = 0b000000000100000000000100001000)
                    onKeyUp  ; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    "LButtonDown"
                    "RButtonDown"
                    "MouseMove"
                    Flags;   131338 (0X02010A = 0b000000000000100000000100001010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 131072 ( VK_SHIFT or CONSTRAIN_MODIFIER_KEY or CONSTRAIN_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 262144 ( VK_CONTROL )
                    "RButtonDown"
                    "RButtonDown"
                    "MouseMove"
                    Flags;   262409 (0X040109 = 0b000000000001000000000100001001)
                    onKeyUp  ; Key code; 262144 ( VK_CONTROL )
                    
                    onKeyDown; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    "LButtonDown"
                    "RButtonDown"
                    "MouseMove"
                    Flags;   524586 (0X08012A = 0b000000000010000000000100101010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 524288 ( VK_ALT or VK_MENU or COPY_MODIFIER_KEY or COPY_MODIFIER_MASK )
                    
                    onKeyDown; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    "LButtonDown"
                    "RButtonDown"
                    "MouseMove"
                    Flags;  1048842 (0X10010A = 0b000000000100000000000100001010)
                    "LButtonUP"
                    onKeyUp  ; Key code; 1048576 ( VK_COMMAND or ALT_MODIFIER_KEY or ALT_MODIFIER_MASK )
                    
                    Key Tool Deactivated.
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • fredo6F Offline
                      fredo6
                      last edited by

                      @slbaumgartner

                      Thanks. Very helpful.

                      Then it means that a portable flag decoding for onMouseMove could be

                      
                      #Flags for onMouseMove
                      if (RUBY_PLATFORM =~ /darwin/i)	
                         def buttonLDown?(flags) ; flags & 2 == 2 ; end
                         def shiftDown?(flags) ; flags & VK_SHIFT == VK_SHIFT ; end
                         def ctrlDown?(flags) ; flags & VK_CONTROL == VK_CONTROL ; end
                         def altDown?(flags) ; flags & VK_ALT == VK_ALT ; end
                      else
                         def buttonLDown?(flags) ; flags & 1 == 1 ; end
                         def shiftDown?(flags) ; flags & 4 == 4 ; end
                         def ctrlDown?(flags) ; flags & 8 == 8 ; end
                         def altDown?(flags) ; flags & 32 == 32 ; end
                      end
                      
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        driven
                        last edited by

                        fredo,

                        you probably don't want to use VK_CONTROL on a mac...

                        256 = onMouseMove
                        258 = onMouseMove with LButtonDown

                        131072 ( VK_SHIFT )
                        131330 = onMouseMove with LButtonDown and ( VK_SHIFT )

                        524288 ( VK_ALT )
                        524578 = onMouseMove with LButtonDown and ( VK_ALT )

                        1048576 ( VK_COMMAND )
                        1048842 = onMouseMove with onLButtonDown and ( VK_COMMAND )

                        Usage example from Move Tool:
                        Shift = Lock move to the current inference direction ( VK_SHIFT )
                        Option = Toggles copy of selection ( VK_ALT )
                        Command =Toggles autofold of selection ( VK_COMMAND )

                        Control behaves differently depending on the order it is chosen...
                        262144 ( VK_CONTROL )
                        262403 = onMouseMove with LButtonDown THEN ( VK_CONTROL )
                        OR
                        262409 = onMouseMove with ( VK_CONTROL ) THEN LButtonDown

                        ( VK_CONTROL ) THEN LButtonDown will show a context menu...
                        LButtonDown THEN ( VK_CONTROL ) will NOT...

                        john

                        learn from the mistakes of others, you may not live long enough to make them all yourself...

                        1 Reply Last reply Reply Quote 0
                        • fredo6F Offline
                          fredo6
                          last edited by

                          Thanks again.

                          Then, with some luck, the following portable code should make it on PC and Mac

                          
                          def buttonLDown?(flags) ; flags & MK_LBUTTON == MK_LBUTTON ; end
                          def shiftDown?(flags) ; flags & CONSTRAIN_MODIFIER_MASK == CONSTRAIN_MODIFIER_MASK ; end   #shift
                          def ctrlDown?(flags) ; flags & COPY_MODIFIER_MASK == COPY_MODIFIER_MASK ; end              #Ctrl (PC) or Command (Mac)
                          def altDown?(flags) ; flags & ALT_MODIFIER_MASK == ALT_MODIFIER_MASK ; end                 #Alt (PC) or Ctrl(Mac)
                          
                          

                          Fredo

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            driven
                            last edited by

                            write a test with some puts and I'll test it...

                            john

                            learn from the mistakes of others, you may not live long enough to make them all yourself...

                            1 Reply Last reply Reply Quote 0
                            • fredo6F Offline
                              fredo6
                              last edited by

                              @driven said:

                              write a test with some puts and I'll test it...

                              john

                              Thanks in advance. I thought initially that the question was resolved somewhere in the forum, but could not find it (and it is anyway not described in the SU API doc).

                              Fredo

                              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