How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
Hi, I'd like to imitate a mouse move event programmaticaly, to refresh the state of my custom view. What is the best way to do it? I am trying to use [NSApp postEvent:atStart:] and [window postEvent:atStart:], but nothing happens, the event is not fired, and the view does not receive it. Here

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
As I said, I am trying to refresh the state of the view after a lengthy operation is complete. By state I mean that the item in the view on which the mouse is hovered, should highlight. Also, if I don't refresh, the view will not respond to the following mouse down event, unless it is preceded

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Graham Cox
On 03/11/2009, at 8:48 PM, Oleg Krupnov wrote: As I said, I am trying to refresh the state of the view after a lengthy operation is complete. No disrespect, but you did not say that - this is the first mention of a lengthy operation. How lengthy? What is it?. Not sure why the coyness but

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
Thanks Graham, There are basically two or three custom views of different class in the window that need refresh. These views are totally custom, which means I could of course implement the corresponding methods that would explicitly refresh their state, but because the state depends on the mouse

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Graham Cox
On 03/11/2009, at 10:39 PM, Oleg Krupnov wrote: There are basically two or three custom views of different class in the window that need refresh. These views are totally custom, which means I could of course implement the corresponding methods that would explicitly refresh their state, but

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
Graham, Maybe I'm not speaking clearly, but that's exactly what I'm trying to do -- use a mouse event to cause a state change, but in this case the mouse event would be fake. Mouse position is in no way part of the view's state. I just want that at particular moment the view's state becomes

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Dave Keck
Untested suggestion: when a real mouse moved event occurs, NSLog it and duplicate its arguments exactly. Perhaps the '0' arguments are why it's not working. If that doesn't do the trick, you'll probably have to drop to a lower level, such as CGEventPost(). ... but Graham's right - there's

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
Dave, I already tried CGEventPost() but it does not seem to work either -- just nothing happens. I'd appreciate an example of working code, I haven't been able to find any. I also tried CGPostMouseEvent(). This works, but in a weird way -- it actually moves the mouse cursor (kind of a too

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Graham Cox
On 03/11/2009, at 11:15 PM, Oleg Krupnov wrote: Maybe I'm not speaking clearly, but that's exactly what I'm trying to do -- use a mouse event to cause a state change, but in this case the mouse event would be fake. Mouse position is in no way part of the view's state. I just want that at

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Oleg Krupnov
Graham, I really appreciate you taking your time to write such detailed posts for me, but what I am trying to say is that I am doing everything exactly as you suggest, following the best design patterns (I think). There is a controller and it maintains the selection. The view only draws the

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Uli Kusterer
On 03.11.2009, at 14:56, Graham Cox wrote: In other words, instead of faking a mouse event in order to get the mouse position into that code, just factor that part out and give it the mouse position at the end. You can get that using - mouseLocationOutsideOfEventStream. Converting it to

Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Steve Christensen
Oleg, had you thought of doing something like adding -isSelectionValid and -setSelectionValid: methods to your controller class? The view would always keep track of the mouse state, tell the controller what the current selection is when the mouse moves, but won't update itself or respond