Hide Cursor - Feature Request #8766

Added the ability to hide or show the cursor on desktop builds.
This commit is contained in:
Chad 2015-02-11 17:21:04 -08:00 committed by Nite Luo
parent e836e98dc4
commit 395c14f07d
3 changed files with 20 additions and 2 deletions

View File

@ -140,7 +140,11 @@ public:
debugging big resolution (e.g.new ipad) app on desktop.*/
virtual void setFrameZoomFactor(float zoomFactor) {}
virtual float getFrameZoomFactor() const { return 1.0; }
/**
* Hide or Show the mouse cursor if there is one.
*/
virtual void setCursorVisible( bool isVisible ){ /* do nothing by default*/ }
/** Get retina factor */
virtual int getRetinaFactor() const { return 1; }

View File

@ -477,6 +477,17 @@ void GLViewImpl::setIMEKeyboardState(bool /*bOpen*/)
}
void GLViewImpl::setCursorVisible( bool isVisible )
{
if( _mainWindow == NULL )
return;
if( isVisible )
glfwSetInputMode(_mainWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
else
glfwSetInputMode(_mainWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
}
void GLViewImpl::setFrameZoomFactor(float zoomFactor)
{
CCASSERT(zoomFactor > 0.0f, "zoomFactor must be larger than 0");

View File

@ -89,7 +89,10 @@ public:
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/
void setFrameZoomFactor(float zoomFactor);
/**
* Hide or Show the mouse cursor if there is one.
*/
virtual void setCursorVisible( bool isVisible );
/** Retina support is disabled by default
* @note This method is only available on Mac.
*/