|
|
Home » U++ Library support » Look and Chameleon Technology » Does SetStyle needs a refresh ?
Does SetStyle needs a refresh ? [message #16752] |
Wed, 09 July 2008 20:44 |
kbyte
Messages: 87 Registered: July 2008
|
Member |
|
|
Hi all,
I download today the latest version of Upp and I have to adapt my app code, basically on SetBkColor calls. Now, I thing we showld use the SetStyle. Well, In a form I want to change the bk of the edit field where the user enters text (OnChange event). I have this code:
void X::OnChangeEditBox(void) //Called from on change event
{
EditField * pEdit=dynamic_cast<EditField*> (GetLastCtrl());
edits=EditField::StyleDefault();
edits.paper=Yellow();
pEdit->SetStyle(edits);
}
Then when I try it I write text on the edit boxes but bkground only get yellow when the Edit box loose the focus and not while I write text to it.
Any help?
Thanks
Kim
[Updated on: Wed, 09 July 2008 21:43] Report message to a moderator
|
|
|
|
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: Sat Dec 14 14:23:09 CET 2024
Total time taken to generate the page: 0.02083 seconds
|
|
|