Fixed CInterface::SetFocus not recursing into windows, this fixes highlighting of compilation errors in the editor

It's not really nice, but at least it works
master
krzys-h 2015-09-11 18:34:45 +02:00
parent 2792fa2c6c
commit 48f24fe6cc
5 changed files with 18 additions and 5 deletions

View File

@ -281,9 +281,10 @@ bool CControl::GetTooltip(Math::Point pos, std::string &name)
// Management of the focus. // Management of the focus.
void CControl::SetFocus(bool bFocus) void CControl::SetFocus(CControl* focusControl)
{ {
m_bFocus = bFocus; // TODO: I don't like this, but it's needed for Ui::CWindow* to work properly
m_bFocus = focusControl == this;
} }
bool CControl::GetFocus() bool CControl::GetFocus()

View File

@ -94,7 +94,7 @@ public:
virtual Gfx::FontType GetFontType(); virtual Gfx::FontType GetFontType();
virtual bool SetTooltip(std::string name); virtual bool SetTooltip(std::string name);
virtual bool GetTooltip(Math::Point pos, std::string &name); virtual bool GetTooltip(Math::Point pos, std::string &name);
virtual void SetFocus(bool bFocus); virtual void SetFocus(CControl* focusControl);
virtual bool GetFocus(); virtual bool GetFocus();
virtual EventType GetEventType(); virtual EventType GetEventType();

View File

@ -335,8 +335,7 @@ void CInterface::SetFocus(CControl* focusControl)
{ {
if (control != nullptr) if (control != nullptr)
{ {
bool focus = control.get() == focusControl; control->SetFocus(focusControl);
control->SetFocus(focus);
} }
} }
} }

View File

@ -1283,4 +1283,15 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
while ( !bStop ); while ( !bStop );
} }
void CWindow::SetFocus(CControl* focusControl)
{
for (auto& control : m_controls)
{
if (control != nullptr)
{
control->SetFocus(focusControl);
}
}
}
} }

View File

@ -114,6 +114,8 @@ public:
void Draw() override; void Draw() override;
void SetFocus(CControl* focusControl) override;
protected: protected:
int BorderDetect(Math::Point pos); int BorderDetect(Math::Point pos);
void AdjustButtons(); void AdjustButtons();