Implementing Photoshop-like focus policy

Bill Baxter wbaxter at gmail.com
Mon Jul 9 13:20:31 PDT 2007


On 7/9/07, Vadim Zeitlin <vadim at wxwidgets.org> wrote:
>
> On Sat, 7 Jul 2007 01:58:07 +0900 Bill Baxter <wbaxter at gmail.com> wrote:
>
> BB> Seems like the proper behavior for pushed event handlers would be for
> only
> BB> the last handler to percolate events up beyond the frame it's pushed
> onto.
> BB>
> BB> I think maybe ProcessEvent in wxEvtHandler could be changed to this:
> BB>
> BB>     [...]
> BB>     // Try going down the event handler chain
> BB>     if ( GetNextHandler() )
> BB>     {
> BB>         if ( GetNextHandler()->ProcessEvent(event) )
> BB>             return true;
> BB>         return false; // <----- NEW ADDITION
> BB>     }
> BB>
> BB>     // Finally propagate the event upwards the window chain and/or to
> the
> BB>     // application object as necessary
> BB>     return TryParent(event);
>
> I agree with your analysis, so I've modified the code like this in the
> trunk. I'm not sure if it should be backported to 2.8 though, as much as
> the new behaviour seems more logical to me, it could be that someone
> expects the old one in 2.8 and I really don't want to create any bad
> surprises (such as silent changes in the event handling logic) for someone
> upgrading from 2.8.4 to 2.8.5.



Ok, I can understand not wanting to muck with the event loop between point
releases, no matter how benign the change may seem.
How long till 3.0?


BB> Note that It doesn't prevent double calls to App's handlers in the case
> BB> where wxApp calls evt.Skip().  But probably App has no business
> calling
> BB> Skip() anyway since it's supposed to be the last stop for events.  I'd
> half
> BB> expect it to go into an infinite loop if you call Skip in the App's
> event
> BB> handler.  That it only gets called one more time is probably a
> feature.
>
> I'm not sure I understand how does it happen that wxApp gets it twice in
> this case and I think it's (still) a bug (albeit a minor one). Could you
> please explain why does it happen like this?
>
> Thanks,
> VZ


Good news, it actually works fine.   There is no second call to the app.  I
had recompiled 'core' after making the change, but not 'base'.  So the extra
call to the App's handler was coming from a wxFrame that hadn't been
recompiled with the fix.  After recompiling base, it's ok with or without
the call to Skip() in the App's handler.

Thanks for applying the change.

--bb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070710/b4b=
21149/attachment.htm


More information about the wx-users mailing list