right mouse click in GEF [message #85023] |
Tue, 24 June 2003 17:31  |
Eclipse User |
|
|
|
Originally posted by: rahul.dhar.intel.com
Is there a way to catch right mouse clicks? I'd like to provide
context-sensitive menus when the user right clicks on an object in my GEF
application. Also, are there any simple example of how to handle mouse
events with GEF?
Thanks,
-Rahul
|
|
|
|
|
Re: right mouse click in GEF [message #85321 is a reply to message #85291] |
Wed, 25 June 2003 11:44   |
Eclipse User |
|
|
|
The ActionRegistry in the logic example's ContextMenuProvider is passed in by
the editor. GraphicalEditor initializes the action registry in createActions(),
which is where the UndoAction is added.
Rahul Dhar wrote:
> For some reason,
> action = getActionRegistry().getAction(GEFActionConstants.UNDO)
>
> always sets action to null. I'm probably forgetting to do something. Do
> I need to register GEFActionConstants.UNDO as an action somewhere before I
> retrieve it?
>
> Thanks,
> -Rahul
>
> Eric Bordeau wrote:
>
>
>>Extend ContextMenuProvider and implement buildContextMenu(IMenuManager)
>
> which
>
>>gets called each time the context menu is about to show. You'll need to add
>>your provider to the viewer -- see LogicEditor.configureGraphicalViewer(),
>>specifically these lines:
>
>
>>ContextMenuProvider provider = new LogicContextMenuProvider(viewer,
>> getActionRegistry());
>>viewer.setContextMenu(provider);
>>
>
> getSite().registerContextMenu("org.eclipse.gef.examples.logic.editor.contextmenu ",
>
>> provider, viewer);
>
>
>
>
>>Rahul Dhar wrote:
>
>
>>>Is there a way to catch right mouse clicks? I'd like to provide
>>>context-sensitive menus when the user right clicks on an object in my GEF
>>>application. Also, are there any simple example of how to handle mouse
>>>events with GEF?
>>>
>>>Thanks,
>>>-Rahul
>>>
>
>
>
>
>
|
|
|
|
Re: right mouse click in GEF [message #85392 is a reply to message #85377] |
Wed, 25 June 2003 15:05   |
Eclipse User |
|
|
|
Here's the sequence of events:
1. Eclipse calls EditorPart.init(IEditorSite, IEditorInput) -- NOTE: If you
override this method in your editor, you *must* call super.init(...). This is
stated in the javadoc of GraphicalEditor.init(...).
2. GraphicalEditor implements init(...) which calls initializeActionRegistry()
3. initializeActionRegistry() calls createActions()
Rahul Dhar wrote:
> Eric Bordeau wrote:
>
>
>>The ActionRegistry in the logic example's ContextMenuProvider is passed in
>
> by
>
>>the editor. GraphicalEditor initializes the action registry in
>
> createActions(),
>
>>which is where the UndoAction is added.
>
>
> So, is createActions() called somewhere? Going through the Logic Example,
> i didn't see any explicit calls to it, so I'm assuming that it's being
> called somewhere, or at least is supposed to be called somewhere. For
> some reason, createActions() isn't being called in my code, and I've
> followed along and even copy/pasted some of the example code into mine.
>
> -Rahul
>
>
>
>
|
|
|
|
Re: right mouse click in GEF [message #85519 is a reply to message #85483] |
Thu, 26 June 2003 10:05  |
Eclipse User |
|
|
|
GEF doesn't provide a default copy action. You can look at the source code for
GraphicalEditor.createActions() to see what actions are provided.
Rahul Dhar wrote:
> Eric,
>
> Thanks a lot! This is hopefully my last question about context-sensitive
> menus. Following the logic example, I'm creating menu in public
> buildContextMenu(IMenuManager manager). However, I keep getting a
> NullPointerException. My code is below. It seems that
> getActionRegistry().getAction(GEFActionConstants.COPY) is always returning
> null. Why is this? What's different about COPY that I don't have this
> problem with UNDO/REDO? The API didn't give any information, and google
> didn't help either.
>
> public void buildContextMenu(IMenuManager manager) {
> IAction action;
>
> GEFActionConstants.addStandardActionGroups(manager);
> action = getActionRegistry().getAction(GEFActionConstants.COPY);
> actionRegistry.registerAction(action);
> manager.appendToGroup(GEFActionConstants.GROUP_COPY, action);
> }
>
> Thanks,
> Rahul
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 1.04856 seconds