This Question is Answered

15 "helpful" answers available (3 pts)
2 Replies Last post: Sep 29, 2008 5:58 AM by Kamal

How to control the effect of mouse right-button?

Sep 28, 2008 1:06 AM

Click to view markecho's profile Level 2 markecho 35 posts since
Oct 17, 2007
HI,
I have some trouble controlling the mouse right-button's menu.

Usually, When I click mouse right-button , a menu (here, I call it Menu-A) will pop up.
alike, when I click mouse right-button while holding the ctrl key , a menu(I call it Menu-B) will pop up.
Menu-A's content is different with Menu-B.

Now, I want to realize the descriptions below:

first of all, because I want to implement some functions, so I call the {disable-inspection-gesture} procedure.

then , I want to realize the effect is
when I click mouse right-button while holding the ctrl key, Menu-A will pop up.

How should I do? many thanks. :-)
Click to view Kamal's profile Curl Kamal 139 posts since
Oct 17, 2007
1. Re: How to control the effect of mouse right-button? Sep 29, 2008 5:26 AM
Here is some code to do that.


{curl 6.0 applet}
 
{do
    || Disable Ctrl+RightClick event to generate an inspection event and hence
    ||  getting consumed. 
    {disable-inspection-gesture}
}
 
{TextField
    {on e:PointerRelease at tf:TextField do
        || Disable ContextMenuEvent for the TextField.
        {e.consume}
        {if e.button == right-button and e.ctrl? then
            def menu-pane =
                {MenuPane
                    {MenuAction
                        label="Show message",
                        {on Action do
                            {popup-message "Hello"}
                        }
                    }
                }
            {menu-pane.popup tf, e.x, e.y}
        }
    }
}
 


Message was edited by: Kamal
Click to view Kamal's profile Curl Kamal 139 posts since
Oct 17, 2007
2. Re: How to control the effect of mouse right-button? Sep 29, 2008 5:58 AM
In the previous approach I had to call "disable-inspection-gesture" to disable the Ctrl+Right-click gestures to be converted to an Inspection event. This meant that no Visual in the entire applet can be inspected.
In this new approach we do not call "disable-inspection-gesture". We use the Inspection event instead.


 
{curl 6.0 applet}
 
{TextField
    {on e:PointerEnvelopeEvent at tf:TextField do
        {if e.contents isa Inspection then
            {e.consume}
            def menu-pane =
                {MenuPane
                    {MenuAction
                        label="Show message",
                        {on Action do
                            {popup-message "Hello!!!"}
                    }
                    }
                }
            {menu-pane.popup tf, e.x, e.y}
        }
    }
}