How to trigger an event when I move the cursor from the text?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-08-23
03:38 PM
- last edited on
‎2021-09-14
09:19 AM
by
Noemi Balogh
I am using StaticTextMouseMoved function for, changed text to red color, but is the method called when cursor positioned over the text, and when I remove the cursor from the text it stays red. How to make it blue?
void Dialog::StaticTextMouseMoved(const DG::StaticTextMouseMoveEvent& ev, bool* noDefaultCursor)
{
leftText_.SetTextColor(Gfx::Color::Red);
}
- Labels:
-
Add-On (C++)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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 }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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 );
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎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.