BaseWidget: Renamed GrabKeyboard to SetFocus, added ClearFocus and focus virtual methods
This commit is contained in:
@@ -40,6 +40,8 @@ namespace Ndk
|
||||
inline void CenterHorizontal();
|
||||
inline void CenterVertical();
|
||||
|
||||
void ClearFocus();
|
||||
|
||||
inline void Destroy();
|
||||
|
||||
void EnableBackground(bool enable);
|
||||
@@ -56,13 +58,12 @@ namespace Ndk
|
||||
|
||||
inline bool IsVisible() const;
|
||||
|
||||
void GrabKeyboard();
|
||||
|
||||
virtual void ResizeToContent() = 0;
|
||||
|
||||
void SetBackgroundColor(const Nz::Color& color);
|
||||
void SetCursor(Nz::SystemCursor systemCursor);
|
||||
inline void SetContentSize(const Nz::Vector2f& size);
|
||||
void SetFocus();
|
||||
inline void SetPadding(float left, float top, float right, float bottom);
|
||||
void SetSize(const Nz::Vector2f& size);
|
||||
|
||||
@@ -85,6 +86,8 @@ namespace Ndk
|
||||
virtual void Layout();
|
||||
void InvalidateNode() override;
|
||||
|
||||
virtual void OnFocusLost();
|
||||
virtual void OnFocusReceived();
|
||||
virtual void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key);
|
||||
virtual void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key);
|
||||
virtual void OnMouseEnter();
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Ndk
|
||||
Canvas& operator=(Canvas&&) = delete;
|
||||
|
||||
protected:
|
||||
inline void ClearKeyboardOwner(std::size_t canvasIndex);
|
||||
|
||||
inline void NotifyWidgetBoxUpdate(std::size_t index);
|
||||
inline void NotifyWidgetCursorUpdate(std::size_t index);
|
||||
|
||||
|
||||
@@ -46,6 +46,12 @@ namespace Ndk
|
||||
return m_world;
|
||||
}
|
||||
|
||||
inline void Canvas::ClearKeyboardOwner(std::size_t canvasIndex)
|
||||
{
|
||||
if (m_keyboardOwner == canvasIndex)
|
||||
SetKeyboardOwner(InvalidCanvasIndex);
|
||||
}
|
||||
|
||||
inline void Canvas::NotifyWidgetBoxUpdate(std::size_t index)
|
||||
{
|
||||
WidgetBox& entry = m_widgetBoxes[index];
|
||||
@@ -67,6 +73,12 @@ namespace Ndk
|
||||
|
||||
inline void Canvas::SetKeyboardOwner(std::size_t canvasIndex)
|
||||
{
|
||||
if (m_keyboardOwner != InvalidCanvasIndex)
|
||||
m_widgetBoxes[m_keyboardOwner].widget->OnFocusLost();
|
||||
|
||||
m_keyboardOwner = canvasIndex;
|
||||
|
||||
if (m_keyboardOwner != InvalidCanvasIndex)
|
||||
m_widgetBoxes[m_keyboardOwner].widget->OnFocusReceived();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user