Drop shape at cursor position and assign the macro to a function key

Started by kiler40, January 30, 2015, 11:20:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kiler40

Hi Again
I feel that this must be something that i can find all over the net - but i really can`t figure it out.
I have a stencil with 2 shapes (one nod and one connector) i want to spread all over the page - hundreds of times.
As a background i have a map where what shape need to be.
So my goal is to point at the map, press a function key (if possible) and voilĂ  - the shape is there.
Can someone help and provide an example file - all i found on the internet I can`t make it work...

P.S.
Next step will be how to quick connect several connectors to one nod...  ;D ;D ;D 8)

Cheers

kiler40

Is it something wrong ? I receive mails about responses to the topic - but i cannot see nothing :/

Yacine

Hi Andrei,
I did prepare an answer to your question, but withdrew it because it was not complete.
Well on Saturday it is still not complete, anyhow my advice would have been to change your strategy.


Instead of pressing a key, do a mouse click.
The mouse click would be trapped by a non-modal form and the mouse position would be recorded, then the right shape dropped at that position.



Now for the details ... and that's where I decided, your post could wait till next week.  ;D
Yacine

kiler40

Fare enough :)
I get to the solution with mouse click. But it is giving a (i think) pixel position of the mouse - not position on drawing. And using a mouse click - i need to enable and disable this feature - i guess :)

kiler40


Yacine

Hi Andrei,
I'm so often too fast with my answers.
Basically both ways Click and Key press can be used.


The solution is to build a mouse listener for the activewindow and catch either a key press or a mouse down event.
This event catcher or listener will only be active when a toggle button on the form is pressed, this way you can switch between adding mode and normal working.
The form itself is set to non-modal to allow to work on the drawing whilst it is shown.

I enclose a stencil, in which the solution is shown. (The vsd is only to have a ready playground)
Drag one of the yellow shapes on the drawing to start the macro.


For fun I added a possibility to drop different masters. The only restriction is, that they must belong to the stencil. Otherwise you'd need to modify the code and add a routine to look in other stencils.


On the key press form, you could even add some text boxes to relate a certain key to a certain master. I'll leave that up to you.
Yacine

Yacine

Yacine

kiler40

Man - AGAIN !
This is amazing.
Now i have one question with this  :-[

in the shape i drop - there is a shape data that need be filled on drop. when i drag and drop from the stencil - the input window shows.
when i use the macro it is dropping without asking anything.
Why is that ?

Yacine

Yes the "ask on drop" seems not to be working when the shape is dropped by a macro.
You can however add a "docmd(1312)" to the ondrop event cell in the events section.
Yacine

kiler40


Gustavo

Hi Yacine. I know this post has been around for quite some time. Anyway, I'm gonna ask for the sake of non repeating. Why I can only make it work with the shapes already in the stencil, and not with other shapes in the sheet, or shapes I import to the stencil? best regards.

Yacine

Guess you mean the data dialog?
Actually you can call from other events. Just write the Docmd in the according field (eg: double click, action, data changed, etc.).
Yacine

Gustavo

Thank you for your answer Yacine, but I didn't mean the data dialog. I meant that, if I add other masters to the stencil, the macro doesn't work with them, even if I save the stencil with the masters added. What am I missing? best regards

Yacine

That is just the simple way I implemented it.
You can easily extend the macro, to not only use masters in the stencil, but any one.

May be a button that asks the user to select the master to use.
Yacine

Gustavo

Brilliant solution for repetitive tasks of dropping multiple shape instances. Thank you.

Just take note other users of this wonderful macro. After some headscratching, I found the macro will only work with the masters universal name . If the local name of a master shape doesn't match the universal name, the master shape instance will not drop with this macro.

Best regards