[interfacekit] Re: Object token -> Object, restoring focus...

On 2004-12-27 at 11:06:07 [+0100], Stefano Ceccherini wrote:
> I have a small problem:
> 
> in BMenuBar there are two functions: StealFocus() and RestoreFocus(), 
which,
> respectively, steal the focus (amazing, isn't it?) from the current 
focused
> BView, saving the object token,  and give it to the BMenu/BMenuBar, and 
> give it
> back to the previous focused object.
> Now, stealing the focus it easy enough, and I could grab the object token 
> using
> "_get_object_token_()", but how do the reverse process ? How do I find 
the 
> right
> BView/object from a token ?
> 
> I guess I could change this to store a pointer to a BView instead of an 
> object
> token, but there has to be a way, right?
> 
> Check here:
> http://cvs.sourceforge.net/viewcvs.py/open-beos/current/src/kits/interface/MenuBar.cpp?rev=1.3&view=markup
> 
> StealFocus() and RestoreFocus()

In the private part of the App Kit there is a class BTokenSpace and a 
global instance gDefaultTokens which manages the BHandler tokens of the 
application. BTokenSpace::GetToken() fed with the token and token type 
B_HANDLER_TOKEN returns the respective BHandler* (as void* through the 
third argument). The callback is usually omitted.

CU, Ingo

Other related posts: