mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(ui): implement handling for key down repeat events
This commit is contained in:
parent
6fa4382bc6
commit
0861448de9
@ -879,6 +879,23 @@ int32_t CSimpleEditBox::OnLayerKeyDown(const CKeyEvent& evt) {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CSimpleEditBox::OnLayerKeyDownRepeat(const CKeyEvent& evt) {
|
||||
if (!this->m_visible) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!CSimpleEditBox::s_currentFocus && this->m_autoFocus) {
|
||||
CSimpleEditBox::SetKeyboardFocus(this);
|
||||
return this->OnLayerKeyDown(evt);
|
||||
}
|
||||
|
||||
if (this->IsCurrentFocus()) {
|
||||
return this->OnLayerKeyDown(evt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleEditBox::OnLayerMouseDown(const CMouseEvent& evt, const char* btn) {
|
||||
int32_t eaten = CSimpleFrame::OnLayerMouseDown(evt, btn);
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
|
||||
virtual void LoadXML(XMLNode* node, CStatus* status);
|
||||
virtual void OnLayerUpdate(float elapsedSec);
|
||||
virtual void OnFrameSizeChanged(float width, float height);
|
||||
virtual int32_t OnLayerKeyDownRepeat(const CKeyEvent& evt);
|
||||
virtual int32_t OnLayerChar(const CCharEvent& evt);
|
||||
virtual int32_t OnLayerKeyDown(const CKeyEvent& evt);
|
||||
virtual int32_t OnLayerMouseDown(const CMouseEvent& evt, const char* btn);
|
||||
|
||||
@ -1080,6 +1080,10 @@ int32_t CSimpleFrame::OnLayerKeyDown(const CKeyEvent& evt) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame::OnLayerKeyDownRepeat(const CKeyEvent& evt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame::OnLayerKeyUp(const CKeyEvent& evt) {
|
||||
if (!this->m_visible || !this->m_onKeyUp.luaRef) {
|
||||
return 0;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef UI_C_SIMPLE_FRAME_HPP
|
||||
#define UI_C_SIMPLE_FRAME_HPP
|
||||
|
||||
#include "event/CEvent.hpp"
|
||||
#include "ui/CRenderBatch.hpp"
|
||||
#include "ui/CScriptRegion.hpp"
|
||||
#include "ui/CSimpleRegion.hpp"
|
||||
@ -97,6 +98,7 @@ class CSimpleFrame : public CScriptRegion {
|
||||
virtual void OnFrameSizeChanged(float width, float height);
|
||||
virtual void OnLayerCursorEnter(int32_t a2);
|
||||
virtual void OnLayerCursorExit(int32_t a2, int32_t a3);
|
||||
virtual int32_t OnLayerKeyDownRepeat(const CKeyEvent& evt);
|
||||
virtual int32_t OnLayerChar(const CCharEvent& evt);
|
||||
virtual int32_t OnLayerKeyDown(const CKeyEvent& evt);
|
||||
virtual int32_t OnLayerKeyUp(const CKeyEvent& evt);
|
||||
|
||||
@ -123,9 +123,24 @@ int32_t CSimpleTop::OnKeyDown(const EVENT_DATA_KEY* pKeyData, void* param) {
|
||||
return eaten == 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleTop::OnKeyDownRepeat(const void* a1, void* a2) {
|
||||
// TODO
|
||||
return 0;
|
||||
int32_t CSimpleTop::OnKeyDownRepeat(const EVENT_DATA_KEY* pKeyData, void* param) {
|
||||
auto top = static_cast<CSimpleTop*>(param);
|
||||
|
||||
int32_t eaten = 0;
|
||||
|
||||
CSimpleFrame* frame = top->m_keydownCapture[pKeyData->key];
|
||||
|
||||
if (frame) {
|
||||
CKeyEvent keyEvent;
|
||||
keyEvent = *pKeyData;
|
||||
keyEvent.id = 0x40060065;
|
||||
|
||||
frame->OnLayerKeyDownRepeat(keyEvent);
|
||||
|
||||
eaten = 1;
|
||||
}
|
||||
|
||||
return eaten == 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleTop::OnKeyUp(const EVENT_DATA_KEY* pKeyData, void* param) {
|
||||
|
||||
@ -36,7 +36,7 @@ class CSimpleTop : public CLayoutFrame {
|
||||
static int32_t OnFocusChanged(const void* a1, void* a2);
|
||||
static int32_t OnIme(const void* a1, void* a2);
|
||||
static int32_t OnKeyDown(const EVENT_DATA_KEY* pKeyData, void* param);
|
||||
static int32_t OnKeyDownRepeat(const void* a1, void* a2);
|
||||
static int32_t OnKeyDownRepeat(const EVENT_DATA_KEY* pKeyData, void* param);
|
||||
static int32_t OnKeyUp(const EVENT_DATA_KEY* pKeyData, void* param);
|
||||
static int32_t OnMouseDown(const EVENT_DATA_MOUSE* pMouseData, void* param);
|
||||
static int32_t OnMouseMove(const EVENT_DATA_MOUSE* pMouseData, void* param);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user