瀏覽代碼

Better way of determining if element is in focus when doing shift-click selection

Marko Pintera 12 年之前
父節點
當前提交
2da8d1311a
共有 4 個文件被更改,包括 6 次插入7 次删除
  1. 1 0
      BansheeEngine/Include/BsGUIInputBox.h
  2. 1 1
      BansheeEngine/Source/BsEngineGUI.cpp
  3. 4 4
      BansheeEngine/Source/BsGUIInputBox.cpp
  4. 0 2
      TODO.txt

+ 1 - 0
BansheeEngine/Include/BsGUIInputBox.h

@@ -59,6 +59,7 @@ namespace BansheeEngine
 		TextSprite* mTextSprite;
 		TextSprite* mTextSprite;
 		bool mIsMultiline;
 		bool mIsMultiline;
 		CM::Int2 mTextOffset;
 		CM::Int2 mTextOffset;
+		bool mHasFocus;
 
 
 		IMAGE_SPRITE_DESC mImageDesc;
 		IMAGE_SPRITE_DESC mImageDesc;
 		CM::WString mText;
 		CM::WString mText;

+ 1 - 1
BansheeEngine/Source/BsEngineGUI.cpp

@@ -230,7 +230,7 @@ namespace BansheeEngine
 		inputBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxNormalTex));
 		inputBoxStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxNormalTex));
 		inputBoxStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxHoverTex));
 		inputBoxStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxHoverTex));
 		inputBoxStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxFocusedTex));
 		inputBoxStyle.focused.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(inputBoxFocusedTex));
-		inputBoxStyle.active.texture = inputBoxStyle.focused.texture;
+		inputBoxStyle.active.texture = inputBoxStyle.normal.texture;
 		inputBoxStyle.border.left = 5;
 		inputBoxStyle.border.left = 5;
 		inputBoxStyle.border.right = 5;
 		inputBoxStyle.border.right = 5;
 		inputBoxStyle.border.top = 5;
 		inputBoxStyle.border.top = 5;

+ 4 - 4
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -28,7 +28,7 @@ namespace BansheeEngine
 
 
 	GUIInputBox::GUIInputBox(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline)
 	GUIInputBox::GUIInputBox(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline)
 		:GUIElement(parent, style, layoutOptions), mInputCursorSet(false), mDragInProgress(false),
 		:GUIElement(parent, style, layoutOptions), mInputCursorSet(false), mDragInProgress(false),
-		mCaretShown(false), mSelectionShown(false), mIsMultiline(multiline)
+		mCaretShown(false), mSelectionShown(false), mIsMultiline(multiline), mHasFocus(false)
 	{
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
@@ -354,9 +354,7 @@ namespace BansheeEngine
 		{
 		{
 			mImageDesc.texture = mStyle->active.texture;
 			mImageDesc.texture = mStyle->active.texture;
 
 
-			bool isElemInFocus = mCaretShown; // HACK - I need a proper way of determining if element is in focus, or is it just now getting focus
-
-			if(isElemInFocus)
+			if(mHasFocus)
 			{
 			{
 				if(ev.isShiftDown())
 				if(ev.isShiftDown())
 				{
 				{
@@ -822,5 +820,7 @@ namespace BansheeEngine
 			clearSelection();
 			clearSelection();
 			markContentAsDirty();
 			markContentAsDirty();
 		}
 		}
+
+		mHasFocus = focus;
 	}
 	}
 }
 }

+ 0 - 2
TODO.txt

@@ -33,10 +33,8 @@ IMMEDIATE:
     - Make sure GUI system uses a dummy texture if one isn't available
     - Make sure GUI system uses a dummy texture if one isn't available
 	- SpriteTexture keeps a static reference to DUmmyTexture which I need to release before shutdown
 	- SpriteTexture keeps a static reference to DUmmyTexture which I need to release before shutdown
 
 
-- Shift+click should select text
 - Writing text in the large text boxes centers the text after I resize the window a bit.
 - Writing text in the large text boxes centers the text after I resize the window a bit.
 - Scrolling the window shouldn't remove text selection
 - Scrolling the window shouldn't remove text selection
-- Clicking an input box when its not focused doesn't move the cursor properly (it stays at the start)
 - Hover colors of the scroll bar are wrong
 - Hover colors of the scroll bar are wrong
 - Ability to scroll by just mousing over and moving the scroll wheel
 - Ability to scroll by just mousing over and moving the scroll wheel