Home » U++ Library support » Look and Chameleon Technology » Does SetStyle needs a refresh ?
Re: SetStyle needs a refresh ? [message #16763 is a reply to message #16753] |
Thu, 10 July 2008 11:15   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
The EditField style has a different colour for focus/unfocused. It was actually me that added it so that I could do exactly what I think you are trying to do (highlight the currently focused EditField).
This has the advantage that you can set it for every EditField in your app with one line:
EditField::StyleDefault().Write().focus = Yellow();
But if you really want to only change the colour when a field has text in it then this works:
void CtrlLibTest::OnEdit(EditField *ctrl)
{
static EditField::Style s = EditField::StyleDefault();
s.focus = Yellow();
ctrl->SetStyle(ctrl->GetLength() ? s : EditField::StyleDefault());
}
Incidentally, you can avoid the need for a dynamic cast by setting the callback to this function with the ctrl as a parameter:
edit1 <<= THISBACK1(OnEdit, &edit1);
edit2 <<= THISBACK1(OnEdit, &edit2);
...etc
Hope that helps!
[Updated on: Thu, 10 July 2008 11:31] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Aug 21 07:13:39 CEST 2025
Total time taken to generate the page: 0.04441 seconds
|