Start re-organizing demos so the physics setup can be shared easier (explicit create graphics objects, init/exit physics etc)
Add B3G_RETURN key code, only implemented in Windows so far (todo: Mac, Linux) Fix Windows key management (use WM_CHAR event instead of WM_KEYUP Add Return (OnKeyReturn) key support TreeNode, so we can select an item using the return key.
This commit is contained in:
@@ -49,17 +49,28 @@ namespace Gwen
|
||||
virtual void SetImage( const TextObject& strName, bool bCenter = false );
|
||||
|
||||
// You can use this to trigger OnPress directly from other controls using GWEN_CALL_EX
|
||||
virtual void ReceiveEventPress( Base* /*pControl*/ ){ OnPress(); }
|
||||
virtual void ReceiveEventPress( Base* /*pControl*/ )
|
||||
{
|
||||
OnPress();
|
||||
}
|
||||
|
||||
virtual void SizeToContents();
|
||||
virtual void Layout( Skin::Base* pSkin );
|
||||
|
||||
virtual bool OnKeyReturn(bool bDown)
|
||||
{
|
||||
onKeyboardReturn.Call(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Gwen::Event::Caller onPress;
|
||||
Gwen::Event::Caller onDown;
|
||||
Gwen::Event::Caller onUp;
|
||||
Gwen::Event::Caller onDoubleClick;
|
||||
Gwen::Event::Caller onKeyboardReturn;
|
||||
|
||||
Gwen::Event::Caller onToggle;
|
||||
Gwen::Event::Caller onToggleOn;
|
||||
Gwen::Event::Caller onToggleOff;
|
||||
|
||||
@@ -72,8 +72,10 @@ void TreeControl::OnNodeAdded( TreeNode* pNode )
|
||||
pNode->onNamePress.Add( this, &TreeControl::OnNodeSelection );
|
||||
}
|
||||
|
||||
|
||||
void TreeControl::OnNodeSelection( Controls::Base* /*control*/ )
|
||||
{
|
||||
//printf("TreeControl::OnNodeSelection\n");
|
||||
if ( !m_bAllowMultipleSelection || !Gwen::Input::IsKeyDown( Key::Control ) )
|
||||
DeselectAll();
|
||||
}
|
||||
|
||||
@@ -132,6 +132,13 @@ void TreeNode::PostLayout( Skin::Base* /*skin*/ )
|
||||
void TreeNode::SetText( const UnicodeString& text ){ m_Title->SetText( text ); };
|
||||
void TreeNode::SetText( const String& text ){ m_Title->SetText( text ); };
|
||||
|
||||
UnicodeString TreeNode::GetText() const
|
||||
{
|
||||
UnicodeString bla = m_Title->GetText();
|
||||
return bla;
|
||||
}
|
||||
|
||||
|
||||
void TreeNode::Open()
|
||||
{
|
||||
m_InnerPanel->Show();
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Gwen
|
||||
|
||||
virtual void SetText( const UnicodeString& text );
|
||||
virtual void SetText( const String& text );
|
||||
UnicodeString GetText() const;
|
||||
|
||||
virtual void Open();
|
||||
virtual void Close();
|
||||
@@ -60,7 +61,18 @@ namespace Gwen
|
||||
virtual void DeselectAll();
|
||||
|
||||
virtual void iterate(int action, int* curIndex, int* resultIndex);
|
||||
|
||||
virtual bool OnKeyReturn(bool bDown)
|
||||
{
|
||||
static bool prevDown = false;
|
||||
if (!prevDown && bDown)
|
||||
{
|
||||
onReturnKeyDown.Call(this);
|
||||
}
|
||||
prevDown = bDown;
|
||||
return Base::OnKeyReturn(bDown);
|
||||
}
|
||||
|
||||
Event::Caller onReturnKeyDown;
|
||||
|
||||
Event::Caller onNamePress;
|
||||
Event::Caller onSelectChange;
|
||||
|
||||
@@ -308,7 +308,7 @@ int main()
|
||||
b3gWindowConstructionInfo wci;
|
||||
wci.m_width = sWidth;
|
||||
wci.m_height = sHeight;
|
||||
wci.m_resizeCallback = MyResizeCallback;
|
||||
// wci.m_resizeCallback = MyResizeCallback;
|
||||
window->createWindow(wci);
|
||||
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
|
||||
@@ -55,8 +55,21 @@ void Win32Window::pumpMessage()
|
||||
int getAsciiCodeFromVirtualKeycode(int virtualKeyCode)
|
||||
{
|
||||
int keycode = 0xffffffff;
|
||||
if (virtualKeyCode >= '0' && virtualKeyCode <= '9')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
if (virtualKeyCode >= 'a' && virtualKeyCode <= 'z')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
if (virtualKeyCode >= 'A' && virtualKeyCode <= 'Z')
|
||||
{
|
||||
return virtualKeyCode;
|
||||
}
|
||||
switch (virtualKeyCode)
|
||||
{
|
||||
case VK_RETURN: {keycode = B3G_RETURN; break; };
|
||||
case VK_F1: {keycode = B3G_F1; break;}
|
||||
case VK_F2: {keycode = B3G_F2; break;}
|
||||
case VK_F3: {keycode = B3G_F3; break;}
|
||||
@@ -126,7 +139,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
{
|
||||
{
|
||||
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
|
||||
|
||||
@@ -140,12 +153,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
case WM_CHAR:
|
||||
{
|
||||
int keycode = wParam;
|
||||
|
||||
if (sData && sData->m_keyboardCallback && ((HIWORD(lParam) & KF_REPEAT) == 0))
|
||||
//skip 'enter' key, it is processed in WM_KEYUP/WM_KEYDOWN
|
||||
int keycode = getAsciiCodeFromVirtualKeycode(wParam);
|
||||
if (keycode < 0)
|
||||
{
|
||||
int state = 1;
|
||||
(*sData->m_keyboardCallback)(keycode,state);
|
||||
if (sData && sData->m_keyboardCallback && ((HIWORD(lParam) & KF_REPEAT) == 0))
|
||||
{
|
||||
int state = 1;
|
||||
(*sData->m_keyboardCallback)(wParam, state);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -322,6 +338,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
default:{
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +39,8 @@ enum {
|
||||
B3G_BACKSPACE,
|
||||
B3G_SHIFT,
|
||||
B3G_CONTROL,
|
||||
B3G_ALT
|
||||
B3G_ALT,
|
||||
B3G_RETURN
|
||||
};
|
||||
|
||||
struct b3gWindowConstructionInfo
|
||||
|
||||
Reference in New Issue
Block a user