Added OS X impl of requestFocus and hasFocus

Signed-off-by: Foaly <foaly.f@web.de>
Signed-off-by: Jan Haller <bromeon@gmail.com>
This commit is contained in:
Marco Antognini 2014-04-23 11:26:44 +02:00 committed by Jan Haller
parent b965ad198b
commit 85291debb4
3 changed files with 58 additions and 0 deletions

View File

@ -187,6 +187,28 @@
} }
////////////////////////////////////////////////////////
-(BOOL)requestFocus
{
// Note: this doesn't imply that the view will get any event.
// The user has to make sure events are forwarded to the view
// with the usual responder chain.
[[m_view window] makeKeyAndOrderFront:nil];
// In case the app is not active, make its dock icon bounce for one sec
[NSApp requestUserAttention:NSInformationalRequest];
return [self hasFocus];
}
////////////////////////////////////////////////////////////
-(BOOL)hasFocus
{
return [NSApp keyWindow] == [m_view window];
}
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)enableKeyRepeat -(void)enableKeyRepeat
{ {

View File

@ -451,6 +451,25 @@
} }
////////////////////////////////////////////////////////
-(BOOL)requestFocus
{
[m_window makeKeyAndOrderFront:nil];
// In case the app is not active, make its dock icon bounce for one sec
[NSApp requestUserAttention:NSInformationalRequest];
return [self hasFocus];
}
////////////////////////////////////////////////////////////
-(BOOL)hasFocus
{
return [NSApp keyWindow] == m_window;
}
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
-(void)enableKeyRepeat -(void)enableKeyRepeat
{ {

View File

@ -166,6 +166,23 @@ namespace sf {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
-(void)closeWindow; -(void)closeWindow;
////////////////////////////////////////////////////////////
/// \brief Request the current window to be made the active
/// foreground window
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
-(BOOL)requestFocus;
////////////////////////////////////////////////////////////
/// \brief Determine whether the window has the input focus
///
/// \return True if window has focus, false otherwise
///
////////////////////////////////////////////////////////////
-(BOOL)hasFocus;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Enable key repeat /// \brief Enable key repeat
/// ///