Capturing toolbar events

M

Martin Stender

Hi all,

Thanks to Shyam Pillai's Autoevents tutorial, I have various eventtraps
active in a project I'm working on. So far so good.

Now my problem (yes, there's always something else...) is to try to
switch between various 'Autoshape Default' setting, based on which
drawing tool the user selects. The reason for this is, that our design
dictates a solid color, but no lines/borders on closed shapes, but on
open shapes (or connectors), the opposite is desired. Otherwise the
users complaint about drawing invisible lines or connectors.

But is it possible to trap 'tool selection events' at all?

If not, could we make our own buttons, set the desired autoshape
default, and then select the tool for the user instead?

Thanks in advance!
Martin
 
S

Steve Rindsberg

Hi all,

Thanks to Shyam Pillai's Autoevents tutorial, I have various eventtraps
active in a project I'm working on. So far so good.

Now my problem (yes, there's always something else...) is to try to
switch between various 'Autoshape Default' setting, based on which
drawing tool the user selects. The reason for this is, that our design
dictates a solid color, but no lines/borders on closed shapes, but on
open shapes (or connectors), the opposite is desired. Otherwise the
users complaint about drawing invisible lines or connectors.

But is it possible to trap 'tool selection events' at all?

I don't believe so, but there's a WindowSelectionChange event that fires
whenever the current selection changes. Since drawing a new shape changes the
selection, you could change the formatting as soon as the user draws the shape
(and vary the format as needed based on the current selection).

You'll need to handle a variety of other selection events in the event handler,
of course (user typed text into a text box ... you don't want to change
anything then, for example).
 
M

Martin Stender

Thank you, Steve.

I have throught this through a bit, and if the WindowSelectionChange
event is the only way, I think it will take too much housekeeping to
get it working in a proper way.

But It might work if I kept track of the number of shapes on a slide.
If that number increased and it wasn't caused be pasting something, I
could check for the type and format it accordingly.
I'm just not sure of how detailed I can check for the selection type,
as a connector and a box seems both seem to be a type '1' shape.

But thank you anyway
Best regards

Martin
 
S

Steve Rindsberg

Thank you, Steve.

I have throught this through a bit, and if the WindowSelectionChange
event is the only way, I think it will take too much housekeeping to
get it working in a proper way.

But It might work if I kept track of the number of shapes on a slide.
If that number increased and it wasn't caused be pasting something, I
could check for the type and format it accordingly.
I'm just not sure of how detailed I can check for the selection type,
as a connector and a box seems both seem to be a type '1' shape.

I haven't done much with connectors but look at help for

.AutoShapeType
.Connector
.ConnectorFormat

For example it looks like:

If oSh.Connector Then
Msgbox "I'm a connector"
Else
Msgbox "I'm NOT a connector."
End if
 
M

Martin Stender

Hi again, and thanks once more for the input.
Now, I've finally had the time to play around with this again.

I can now detect if a connector (or anything else) is selected and if
the number of shapes on the slide has increased.
In other words, I can choose to do nothing, unless the user have drawn
a new open shape, and then make sure it's line is visible (or has the
default color).

So far so good.

But in the case of a paste or a clone (ctrl-drag), I really don't want
the code to force a visible line or anything else. The reason for this
is, that in some cases, the user might need a white line, if there is a
dark-colored rectangle under it, for example. If they copy that object,
this code will keep formatting the copies, driving them nuts ... :)

So I guess what I'm asking is this:
can I detect if the user has pasted (or cloned) something, before
deciding if to format the object for her/him?

Thanks in advance!
Martin
 
S

Steve Rindsberg

But in the case of a paste or a clone (ctrl-drag), I really don't want
the code to force a visible line or anything else. The reason for this
is, that in some cases, the user might need a white line, if there is a
dark-colored rectangle under it, for example. If they copy that object,
this code will keep formatting the copies, driving them nuts ... :)

So I guess what I'm asking is this:
can I detect if the user has pasted (or cloned) something, before
deciding if to format the object for her/him?

So the problem is distinguishing between a newly created shape and one that's
been created, formatted by you and then had its formatting overridden by the
user. I think? ;-)

If you apply a tag to the shape when you format it, then the next time it's
selected, you could check for the tag. If it's non-blank then it's a shape
you've already formatted, meaning that you shouldn't format it again ... it's
either properly formatted already OR it was formatted and now the user has
overridden your formatting.

Make sense?
 
M

Martin Stender

Hi again again,

Yes, of course! Tags are great for distinguishing between various
shapes. Thanks!

But - and I'm sorry I wasn't clearer in my previous post - my real
problem is to distinguish between newly created shapes and shapes that
have been pasted or cloned.
That, I think, isn't really possible in PPT... :-(

Thanks!
Martin
 
S

Steve Rindsberg

Hi again again,

Yes, of course! Tags are great for distinguishing between various
shapes. Thanks!

But - and I'm sorry I wasn't clearer in my previous post - my real
problem is to distinguish between newly created shapes and shapes that
have been pasted or cloned.
That, I think, isn't really possible in PPT... :-(

Yes ... I see what you mean.
No, I don't think it'd be possible ... darn.
 
M

Martin Stender

Thanks Steve,

I was about to give up on it, but thought I'd run it past you guys one
final time, before letting it go.

So I'll probably end up with a togglebutton on the panel, so the user
can disable the automatic formatting of new shapes, if they need to.
That should solve 99%.

Thanks!
Martin
 

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