Right click and selected shape

  • Thread starter Florent, See-Visio PM
  • Start date
F

Florent, See-Visio PM

Hi,

I develop on Visio application for 7 years now and there is a problem I
cannot solve.

I need to customize my right click on an object depending on several
parameters.
My function takes one or two seconds to calculate the contain of the right
click menu to be displayed.


My problem is the following :
How can I know exactly the shape my right click is on?


- If I use the visEvtCodeMouseUp event, sometimes MyWindow.Selection.Count=0
so I don't know which object to take to calculate my right-click menu
content.

- If I use the visEvtCodeWinSelChange, my menu is already displayed,
so it's too late.

I don't have any event beetween those two events.
Before the first event, the selection is not set, after the second event,
the menu is already displayed.

I've already try the SpatialSearch method to recognize the shape I was on,
but I didn't succeed to predict
exactly the shape that was about to be selected by my right click. And the
consequences can be desastrous
for my application if I display a right click on a wrong shape.

For now, I had got to degradate the general ergonomy of my application by
forcing selection before making a right click to have the menus displayed.

What can I do to have a 'natural' right click?
 
D

David J Parker [MVP Visio]

Hmmm ... are you always modifying the right mouse menu in code?
I have my custom right mouse menu defined in the ShapeSheet and the visible
or enabled properties are referencing the values in User-defined cells.
These values could be evaluated using QUEUEMARKEREVENTS to run your code.
 
D

David J Parker [MVP Visio]

.... you will need to pass through the shape id.
Not sure if this will evaluate before your right mouse menu appears, but
worth a try.

David J Parker said:
Hmmm ... are you always modifying the right mouse menu in code?
I have my custom right mouse menu defined in the ShapeSheet and the
visible or enabled properties are referencing the values in User-defined
cells. These values could be evaluated using QUEUEMARKEREVENTS to run your
code.
 
A

Andy

How about taking the x,y position given for the mouse event and doing
a spatial search to find your shape.
 
F

Florent, See-Visio PM

First of all, thank you for your replies.

Andy, I've already tried a spatial search strategy. The point is that you
have got to predict which shape Visio will select after your right click.
The problem is to set the Tolerance parameter of the function to have the
same behaviour than Visio will have.
To help you, I can tell you that, for having spent a lot of time on it, the
Tolerance depends on :
- the scale
- the zoom factor.

David,
We previously used the shapesheet to set the right click, but it was easier
for us to maintain 'dynamic' right clicks.
It also gives the possibility to have hierarchical right clicks.

Anyway I found it hard to understand not having the shape choosen by Visio
for the right click in the API. I hope they solved this problem in Visio 2010.

But I never succed in finding the exact formula that fits the Visio behavior.
 

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