1 2 Previous Next 27 Replies Latest reply on Nov 27, 2012 6:16 AM by datastride

    Which Mouse Button Was Clicked?

    user12837

      I need to write a script which branches depending upon which mouse button (left or right) was clicked on the FM button button which evokes the script. How do I do that?

       

      Thanks,

       

      Tom

        • 1. Re: Which Mouse Button Was Clicked?
          jml

          Try branching on:

          If( Get(ActiveModifierKeys) = 4 )

             …

             …

          End If

          1 of 1 people found this helpful
          • 2. Re: Which Mouse Button Was Clicked?
            datastride

            I believe the  Get( ActiveModifierKeys) test jml suggested just tells you if the "CTRL" or "Control" key was held when the button was clicked.

             

            On Windows it doesn't tell you anything about the right mouse button. Haven't tried it on Mac OS X.

            • 3. Re: Which Mouse Button Was Clicked?
              BruceHerbach

              Tom,

               

              What are you trying to do?  For the most part,  the mouse will open a menu when you right click on an item.  For instance try right clicking on a field and you get a menu diplaying  Cut,Copy paste, fonts ... I believe that with FM Advanced,  you can use Custom menus to change the menu and add scripts to do something specific when an item is selected.

               

              Bruce

              • 4. Re: Which Mouse Button Was Clicked?
                user12837

                This gets me by:

                 

                Try branching on:

                If( Get(ActiveModifierKeys) = 4 )

                End If

                 

                so thanks much.  But it would be nice if FileMaker had an onRightMouseClick (or something like that) like the one Access has.

                 

                Tom

                • 5. Re: Which Mouse Button Was Clicked?
                  datastride

                  Tom,

                   

                  Keep in mind that Get( ActiveModiferKeys ) = 6 also means the "CTRL" or "Control" key was pressed, but when the Caps Lock was also engaged. So check for either value (4 or 6) to see if th "CTRL" or "Control" key was pressed.

                   

                  Any value other than 4 or 6 means some other modifier key was pressed, either by itself or at the same time as the "CTRL" or "Control" key.

                  • 6. Re: Which Mouse Button Was Clicked?
                    jormond

                    I have a feeling that since most applications use the right-click as the context menu, they haven't seen a need to include a function for it.

                     

                    We can somewhat control the context menu through custom menus...but it would be nice to have more granular control over it.

                    • 7. Re: Which Mouse Button Was Clicked?
                      comment

                      Morgan Jones wrote:

                       

                      So check for either value (4 or 6) to see if th "CTRL" or "Control" key was pressed.

                       

                      Any value other than 4 or 6 means some other modifier key was pressed, either by itself or at the same time as the "CTRL" or "Control" key.

                       

                      Actually, you should check for =

                       

                      Mod ( Div ( Get (ActiveModiferKeys) ; 4 ) ; 2 )

                       

                      which will return True when the Control key was pressed - either by itself or together with some other modifier key.

                      • 8. Re: Which Mouse Button Was Clicked?
                        datastride

                        Michael's suggestion is correct ... but it does not allow you to differentiate between a user pressing JUST the Control key and a user pressed, for example, Shift AND Control at the same time.

                         

                        In many aplications, I perform one specific function when Control is pressed by itself, and a different specific action when Shift + Control are both pressed ... just as most shrink-wrapped applications do.

                         

                        If you want to check for the Control key being pressed BUT WITH NO OTHER modifier keys, you should check for the values 4 or 6, as I indicated earlier.

                        • 9. Re: Which Mouse Button Was Clicked?
                          comment

                          Morgan Jones wrote:

                           

                          In many aplications, I perform one specific function when Control is pressed by itself, and a different specific action when Shift + Control are both pressed ... just as most shrink-wrapped applications do.

                           

                          IMHO,  you should be testing for Shift AND Control. That will free you from worrying about Caps Lock as well as any other modifier key the user may have his fat fingers on.

                          • 10. Re: Which Mouse Button Was Clicked?
                            datastride

                            Well Michael, as often happens, I see the situation differently than do you. I am testing SPECIFICALLY for Shift + Control and NOTHING ELSE (disregarding the Caps Lock key). Shift + Alt + Control (for example) could be used to trigger yet another specific action and would not be equivalent to Shift + Control without the Alt key also being pressed.

                             

                            For these kinds of "power user" actions, triggered by the clicking of a button in conjunction with pressing one or more modifier keys, I want to be sure I know exactly what action the user desires. So fat fingers produce the same result here as they would during data entry or at any othe time -- namely an error.

                             

                             

                            • 11. Re: Which Mouse Button Was Clicked?
                              comment

                              If I understand correctly, you are saying that when the combination of Shift + Alt + Control  is NOT defined as "another specific action", pressing that combination should result in an error (or at least no action at all?) - even if the combination of Shift + Control IS defined as a specific action.

                               

                              Whereas I say that in such case the Shift + Control action should be triggered. I'd suggest you test a few well-behaved established applications to see which direction they prefer.

                              • 12. Re: Which Mouse Button Was Clicked?
                                datastride

                                Michael,

                                 

                                I have yet to find an established application that works the way you recommend. Do you know of any example?

                                 

                                Take Excel 2010 (Windows) as an example of an "established application". Select a block of of cells (can be empty, doesn't matter), say two rows high by maybe 5 columns wide. Now type CTRL + period. Do it again, and again. This moves to the next cell within the selection, going in a clockwise direction. Now type Shift + CTLR + period. Nothing. Alt + CTRL + period. Still Nothing. Clearly Excel doesn't follow your recommended model.

                                 

                                I think having an application respond to, for example, Shift + Control in exactly the same manner as Shift + Control + Alt is just sloppy, as even if there is no operation currently defined for Shift + Control + Alt, that doesn't mean one won't be added in the future.

                                • 13. Re: Which Mouse Button Was Clicked?
                                  comment

                                  Well, I said "well-behaved" application... Take Apple Mail, for instance:

                                   

                                  Click = select item

                                  Shift+Click = extend/constrain contiguous selection

                                  Command+Click = add/remove single item to selection

                                   

                                  Now:

                                  Option+Click = undefined, behaves same as Click

                                  Option+Shift+Click = undefined, behaves same as Shift+Click

                                  Shift+Command+Click = undefined, behaves same as Command+Click

                                  Option+Shift+Command+Click = undefined, behaves same as Command+Click

                                  • 14. Re: Which Mouse Button Was Clicked?
                                    datastride

                                    So we have examples of two widely-used, established applications that take different approaches.

                                     

                                    Given that a majority of FileMaker users (not developers) use Windows, I guess I'll stick with the Microsoft approach. And here's a bit more justification:

                                     

                                    Take a situation where action A was defined for Control + Click and action B was defined for Shift + Click.

                                     

                                    Now say the user enters Shift + Control + Click. What action would you take? Would you have a special rule that would do nothing in this case, while equating Alt + Shift + Click to Shift + Click and Alt + Control + Click to Control + Click?

                                     

                                    With my recommended approach, Shift + Control + Click would do nothing, as no action has been associated with this specific set of modifier keys.

                                     

                                    I just prefer the simplicity, lack of ambiguity, and extensibility of the Mcrosoft approach, and I really don't see any down side for the user.

                                    1 2 Previous Next