Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling a defualt popup menu

Status
Not open for further replies.

CleoMan

Programmer
Jun 18, 2003
110
ZA
I have a table frame in one of my forms.

What i want to do is that when a user right clicks on a specific record in the table frame, it should give the option of printing that single record.

The problem however is that when the user right clicks on the record, a pop up menu is opened with the "Locate" and "Locate next" options.

SO what i would like to know is how do i disable the original popup, and load the one i created. (I do know how to create my own popup menu)

Thanks in advance
Richard

 
Cleoman,

You will need to open the table frame in design mode. Look in object explorer in the events tab, the pop up window code should be under one of the mouse events. I guess you will need to replace that code with your code for printing.

Trust this helps,

Lewy
 
Here is an example for what you want to do. You will need to change this to the mouserightdown event on the record object and add the code to extract and print the report on the menu action method.

method mouseRightDown(var eventInfo MouseEvent)
var
pop popupmenu
choice string
endvar
DISABLEDEFAULT
POP.ADDTEXT("1 = Hourly",MenuEnabled,Usermenu+21)
POP.ADDTEXT("2 = Salary",MenuEnabled,Usermenu+22)
choice = pop.show()
IF
choice <> &quot;&quot; and Self.isedit()
THEN
self.value= format(&quot;W1,AL&quot;,CHOICE)
ENDIF

endMethod
 
hcts,

Actually, there's a better way to do this: override the action that displays the popupMenu, not the mouse event. Why? Because there's a keyboard shortcut for the shortcut menu (F6, if memory serves).

You would do this in an action event, as shown below:

Code:
method action(var eventInfo ActionEvent)
var
   str  String
endVar

   if eventInfo.id() = editProperties then

      str = pmShortcut.show()
      if str <> &quot;&quot; then
         doSomething( str )
      endIf

      ; block default behavior
      eventInfo.setErrorCode( userError )

   endIf

endMethod

In this example, pmShortcut is assumed to exist and doSomething() would be a custom method design to determine and handle the selected menu command.

Also, note that I blocked the default behavior of the editProperties action by setting an error code that does nothing. This is my preferred way to block actions, though others feel differently.

Sometimes you need to use disableDefault, but this can lead to unintended side effects, so I usually try using setErrorCode() and then only use disableDefault when necessary.

By and large, it's better to override actions than specific user interface mechanisms, e.g. the right mouse click. By doing so, you cover all the ways the action is triggered.

Hope this helps...

-- Lance
 
Your right, however my users sometimes want to be able to access the Filter option on the field. By trapping for the mouseclick and then allowing the keystoke I provide the user both options in this case. In most situations I do trap for the action method and then any event that generates that action is taken care of.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top