2021-08-23 03:38 PM - last edited on 2021-09-14 09:19 AM by Noemi Balogh
void Dialog::StaticTextMouseMoved(const DG::StaticTextMouseMoveEvent& ev, bool* noDefaultCursor)
{
leftText_.SetTextColor(Gfx::Color::Red);
}
2021-08-23 07:13 PM - last edited on 2021-09-08 09:04 PM by Laszlo Nagy
Haven't tried, but maybe the event arrives even if the mouse is not over the control. If so, than you can check the mouse position, and detect if it is over the control.
Int32 xPos = ev.GetMouseOffset ().GetX ();
Int32 yPos = ev.GetMouseOffset ().GetY ();
if (xPos > 0 && xPos < staticText.GetWidth () && yPos > 0 && yPos < staticText.GetHeight ()) {
// mouse over the control
} else {
// mouse not over the control
}
2021-08-24 12:00 PM
Viktor wrote:
Haven't tried, but maybe the event arrives even if the mouse is not over the control. If so, than you can check the mouse position, and detect if it is over the control.
Int32 xPos = ev.GetMouseOffset ().GetX (); Int32 yPos = ev.GetMouseOffset ().GetY (); if (xPos > 0 && xPos < staticText.GetWidth () && yPos > 0 && yPos < staticText.GetHeight ()) { // mouse over the control } else { // mouse not over the control }
2021-08-24 08:27 PM - last edited on 2021-09-08 09:06 PM by Laszlo Nagy
I dont know a simple solution. Some tricks, schematically.
1. Dont use changing of text color, but use changing of cursor (hand).
( There is some ready handler in UDLib, UDLinkItemHandler.hpp )
2. Use PanelIdle event trick
Enable idle event in dialog constructor and attach to the DG::PanelObserver
EnableIdleEvent();
Attach( *this );
virtual void Dialog::PanelIdle (const PanelIdleEvent& ev)
{
MousePosData mp;
mp.Retrieve(*this);
Gfx::Color color = mp.GetItem() == &leftText_ ? Gfx::Color::Red : Gfx::Color::Blue;
// to avoid flickering
if ( leftText_.GetTextColor() != color )
leftText_.SetTextColor( color );
}
2021-09-07 10:16 AM
There is a specific control in the UD library for displaying links: UD::LinkText. You can find it in the UDLinkText.hpp.