Skip to main content
Known Participant
January 17, 2014
Question

Get mouse position during Custom UI Draw event?

  • January 17, 2014
  • 2 replies
  • 1254 views

I am building a Custom UI for one of my plugin effect.

I want to get the mouse position during the Custom UI Draw event (PF_Event_DRAW), but cannot manage to get it.

From what I understand, it seems we can only get the mouse position during the events PF_Event_DRAG, PF_Event_DO_CLICK, and PF_Event_ADJUST_CURSOR.

I tried to use PFAppSuite4::PF_GetMouse() too, but this resulted in the error message "After Effects error: internal verification failure, sorry! {PF_GetMouse can only be called during valid events.}".

Therefore I want to store the mouse position during PF_Event_ADJUST_CURSOR, and use it later during PF_Event_DRAW.

Where can I store those values in a "clean" way (ensuring there will not be conflicts if two instances of the same effect are running, etc)?

Or is there an easier method to get the mouse position during a Custom UI Draw event?

This topic has been closed for replies.

2 replies

Known Participant
November 7, 2017

This is still the case.

90% of the entire PPRO and AE SDK appears to be vastly outdate and bug infested. Most of the stuff just doesn't work reliably.

More's the pity that the Adobe doesn't update the SDK Guides and Header Documentation.

It could save any company valuable time.

Getting the mouse coordinates on a Mac is very very easy as is drawing.

If you want to save yourself a couple of heart attacks and 100s of hours do all events via NSView/NSControl and draw without the drawbots via [NSGraphicsContext currentContext].

I seriously hope that Adobe will recognize that it is 2017 and that Objective Oriented Programming has been around for more than 20 years. Imagine the luxury UIs we could build if PPRO and AE weren't procedural and capable of introspection !

Community Expert
January 17, 2014

well... old time sample project show the use of continue_refcon[4] to store

mouse positions in.

if an array of 4 longs, in which you can store whatever you want. (it's in

the mouse click event extra data structure)

however, that's hardly good enough for anything. it's not even good enough

for storing pointers to some other data.

what i do, is store al my different UI bits data in separate structures in

sequence data, and then associate the right data pointer to the right

param/comp window/layer window, before processing the call.

life has been much easier since i implemented that method.

wil_Author
Known Participant
January 17, 2014

I tried to use the continue_refcon[4] hack by storing my data from PF_Event_ADJUST_CURSOR, but the value was reset to zero when PF_Event_DRAW was called.

Thank you for the other suggestion, I will try that method, then I can store more valuable data (not only mouse position).

Community Expert
January 17, 2014

//SequenceDataVars is the name of your data structure

//this is how you create the sequence data

out_data->sequence_data = PF_NEW_HANDLE(sizeof(SequenceDataVars));

SequenceDataVars *seqData =

(SequenceDataVars*)PF_LOCK_HANDLE(out_data->sequence_data);

//and now you can store stuff in it.

seqData->var1 = 7;

//after it's created, on other calls, you just do a simple cast

SequenceDataVars *seqData = *(SequenceDataVars **)out_data->sequence_data;

seqData->var1 = 100;

//this is how you delete it. (if you don't delete it, it will be saved with

the project, and loaded on the next session. (if you want)

PF_DISPOSE_HANDLE(out_data->sequence_data);

there's more to know, so look up SequenceSetup, SequenceSetdown, ect in the

sample project.