Re: How to correctly determine the selected action, from a mouse select?
Re: How to correctly determine the selected action, from a mouse select?
- Subject: Re: How to correctly determine the selected action, from a mouse select?
- From: Brian Krisler <email@hidden>
- Date: Mon, 18 Jan 2010 11:25:23 -0500
Interesting idea. I realized after my post that I am also watching
kAXMenuItemSelectedNotification however for my application, an app
geared towards learning and skill acquisition, I need to distinguish
between keyboard and mouse selected events. So my pattern was to have
both kAXMenuItemSelectedNotification an
event monitoring in series and then try to intelligently determine the
mouse or keyboard
execution of the action. I am now leaning towards the possibility of
using timestamps,
since event taps provide a timestamp of the event. Now if I can
figure out how to extract a timestamp from the accessibility object.
Brian
On Mon, Jan 18, 2010 at 11:17 AM, Chen Wang <email@hidden> wrote:
>
> My solution may not be the best for you, but it works well for me.
>
>
>
> Instead of hooking mouse event, I’m listening for two notifications: kAXMenuItemSelectedNotification and kAXSelectedChildrenChanged. In my case, the advantage is that I don’t need to take care of whether the active menu item is selected by mouse or keyboard, but the disadvantage is that I do need to take care of tracking the front-most application, means, when the front-most application switched, the notification listener has to be uninstalled/reinstalled. By the way, if you are only listening to your own application’s menu, the carbon event kEventMenuTargetItem could be an alternative.
>
>
>
> Regarding to your case A, my guess is that you are using CGEventTap as a passive listener, if so, the menu command handler and your event handler are working in a race condition, the result is speculative. So, if you are using kCGEventTapOptionListenOnly constant in the function call to CGEventTapCreate, it is worth to give another try with kCGEventTapOptionDefault.
>
>
>
> Chen
>
>
>
> ________________________________
>
> From: accessibility-dev-bounces+chen.wang=email@hidden [mailto:accessibility-dev-bounces+chen.wang=email@hidden] On Behalf Of Brian Krisler
> Sent: Sunday, January 17, 2010 2:36 PM
> To: email@hidden
> Subject: How to correctly determine the selected action, from a mouse select?
>
>
>
> Hi,
>
>
>
> I am developing an application that relies on the accessibility API. My application
>
> requires knowledge of the mouse selected action (i.e. Edit, Copy). To gain
>
> access to this action, I have tried two different approaches, EventTaps and EventHandlers.
>
>
>
> Using both of these methods, I have placed listeners on both mouse up and mouse down
>
> events. When the event is observed, I grab the accessibility object at the mouse point.
>
>
>
> However, in both approaches, I have observed instances where the selected action is
>
> not reported correctly, depending on the 'habit' of the individual.
>
>
>
> For example:
>
>
>
> A) If the subject Clicks on 'Edit' and releases on 'Select All', the reported events would be:
>
> Mouse Down: Edit
>
> Mouse Up: What ever object is under 'Select All'.
>
>
>
> B) If the Subject Clicks and releases on 'Edit', then clicks and releases on 'Select All', there are 4 events:
>
> Mouse Down: Edit
>
> Mouse Up: Edit
>
> Mouse Down: Select All
>
> Mouse Up: Select All
>
>
>
> For Case B, I can get the proper action 'Select All'. However it is case A that I miss the action. Is there
>
> a more appropriate method for determining the executed action that the approaches outlined above? Since
>
> I have no control over the selection habits of my user base, I am obligated to design my software to
>
> handle both cases above.
>
>
>
> An even more random case is one where the select results in the dismissal of a window (Send mail for example).
>
> In this case the Mouse Down would be the send button and Mouse Up would be the action under the composed
>
> window.
>
>
>
> Thanks for any suggestions/ideas.
>
>
>
> Brian Krisler
>
>
>
> Confidentiality Notice:
> E-mail may be intercepted between the sender and the receiver and is
> therefore neither secure nor confidential. Your continued use of e-mail
> communication confirms that you accept this risk. If this is an urgent
> matter, please contact me at the phone number provided. This e-mail,
> including any attachments, is for the sole use of the intended recipient(s)
> and may contain private, confidential, and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited. If you
> are not the intended recipient or this information has been
> inappropriately forwarded to you, please contact the sender by reply
> e-mail and destroy all copies of the original.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden