Databases - Right Click
Right clicking the mouse generally gives context sensitive help.
Paradox
| MS Access
| Delphi
| Visual Basic
| Java
Paradox
MS Access 97
There is no "Right Click" event - instead you can
use one of 2 ways to handle Right Mouse clicks
- Attach a pop-up menu to ShortcutMenuBar property
- Use the MouseUp event
Pop-up Menus
Define a pop-up menu and attach it to the
control's ShortcutMenuBar property.
In order to define a pop-up menu
- From the menu, select View / Toolbars / Customize...
- On the Toolbars tab, click New...
- Use drag and drop to populate the toolbar with existing items.
WARNING:
| Be SURE to use the control key to copy selections ...
the default is to MOVE them!
|
- When you are finished populating the toolbar,
click the Properties button in the
Customize dialog box and change the Type
to popup.
Onec this is done, there is no way to re-name the pop-up,
change its properties, ot to delete it.
In order to edit a pop-up menu contents (the line items)
- From the menu, select View / Toolbars / Customize...
- On the Toolbars tab, check Shortcut Menus
- In the Shortcut Menus toolbar, select Custom.
The pop-up menu shold be listed.
- Use drag and drop to populate your menu with existing items.
WARNING:
| Be SURE to use the control key to copy selections ...
the default is to MOVE them!
|
- Right click a menu entry to edit it
In order to attach your custom pop-up menu to a
control's ShortcutMenuBar property,
simply click the property's down arrow and
select the appropriate definition.
MouseUp Event
- Attach your code to the MouseUp event
- Check to see which mouse button was pressed
- Cancel the default Right Click action - you must use a macro,
not an event procedure. The following code does not work!
Private Sub FieldName_UIField_MouseUp _
(Button As Integer, Shift As Integer, X As Single, Y As Single)
If ((Button And acRightButton) > 0) Then
OpenDialogBox_UserCode ' This is the application dependent action
DoCmd.CancelEvent ' This cancels the default action ... NOT
End If
End Sub
Notes:
- DoCmd.CancelEvent will not work in a MouseDown event,
but it will work in a macro.
- With an edit field, CancelEvent in a macro
stops the default pop-up menu from displaying.
Well, the help says that to disable the default pop-up menu -
simply set the ShortcutMenuBar property to a value
that isn't the name of an existing shortcut menu or menu bar macro.
As usual, that doesn't work - it mearly generates an error and then
opens the default menu.
I tried setting the property to a null subroutine - but that
popped up a small empty box.
I even tried creating a macro to cancel the event,
but the default pop-up still displayed.
Delphi 5.0
There is no "Right Click" event - instead you can
use one of 3 ways to handle Right Mouse clicks
- Attach a pop-up menu to PopupMenu property
- Use the ContextPopup event
- Use the MouseUp event
Pop-up Menus
Simply define a pop-up menu and attach it to the
control's PopupMenu property.
Normally, you should also set the menu's
AutoPopup property to true.
ContextPopup Event
This is basically a "Right Click" event except that
other actions that open a context menu
will also call it
(such as Ctrl-Shift-F10 or pressing the keyboard's pop-up key).
Set the Handled parameter to True
to suppress the default context menu.
procedure TForm1.Edit1ContextPopup(Sender: TObject; MousePos: TPoint;
var Handled: Boolean);
begin
end;
MouseUp Event
- Attach your code to the MouseUp event
- Check to see which mouse button was pressed
- Cancel the default Right Click action
(I do not know how to this)
procedure TForm1.Edit1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if mbRight in Button then
Some_Function;
end;
Visual Basic 6.0
Java
Author: Robert Clemenzi -
clemenzi@cpcug.org