Custom context menus on right-click

  • Thread starter Chris Roth [MVP]
  • Start date
C

Chris Roth [MVP]

Hi All,

Well, it's only January 3rd and this expert is stumped! I'm wondering if
anybody has solved this problem, or is it simply a "limitation" ; )

Scenario:

We want to create a custom context menu when a user right-clicks a Visio
shape or selection. This right-click menu will change, depending on what is
in the selection.

Problem:

The SelectionChanged doesn't fire until AFTER the right-click menu is built
and displayed.

We don't want to build the menus in the ShapeSheet. We want to go through
CommandBars or Visio UI.

Thanks for any wisdom!

Chris Roth
Visio MVP
 
K

Kari Yli-Kuha

Hi Chris,

I'm stumped as well, because I'm using Window.SelectionChanged event as
well with no problems to add VisioUI menu in visUIObjSetCntx_DrawObjSel

Also, Visio Event monitor shows that it's done in right order.

env: Visio 2003, C#/.NET

/C
 
K

Kari Yli-Kuha

Oops... I answered too quickly...

Yes, I see what you mean.
We've adviced our users to _first_ select the shape (left-click)
and after that right-click.

Right-click only seems to trigger the selecteion changed event too late,
just as you said.

Very interesting...

/C
 
A

Al Edlund

Chris,
It's interesting to watch with the event monitor. It appears that the
context menu comes from a right mouse click (button two down, followed by a
button two up). Also if you put in an event handler for right mouse up
events, then you lose the action menu (you can write your own at this
point).
al
 
N

nbelyh

Hi Chris,
We have solved this as following: [or "doing the sunrise manually"] :)

1. Handle Right MouseUp event and not SelectionChanged event.
2. On MouseUp, get:
- Current window selection.
- Shape under cursor (using SpatialSearch with cursor coordinates).
3. Analyze the above two to determine which shape will be selected and
how to update the menu. Current selection is needed for the case when
you are interested in handling sub-selection, and current selection is
a sub-seleced shape. In this case you'll have to recursively analyze
sub-shapes.
4. Update the context menu at your wish (menu at
visUIObjSetCntx_DrawObjSel)
5. Call UpdateUI

This should do :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top