guiismiti
29th March 2017, 17:57
Hello again
Like the title says, I'm trying to change the background of a menu window onFocus.
I did it successfully by making two windows - unfocus_window and focus_window, with the desired background colors.
Then I used onFocus in the text that is over the window:
onFocus
{
hide unfocus_window;
play "mouse_over";
show focus_window;
}
The only problem I have is how to change the color back "onUnFocus".
How can I do it?
Edit: I'm not sure if there is an easier way, but I'm going to create a button under the window which is slightly bigger, and I'm gonna use onFocus on it.
Edit #2: It works :)
If there is an easier way than this workaround, please let us know.
Here is the code:
itemDef
{
name "unfocus_window"
style WINDOW_STYLE_FILLED
rect 275 375 90 30
backcolor 0.2 0.8 0.2 .3
border 1
bordercolor 1 0.5 0 1
visible 1
decoration
}
itemDef
{
name "focus_window"
style WINDOW_STYLE_FILLED
rect 275 375 90 30
backcolor 1 0.6 0.3 .3
border 1
bordercolor 0 1 0 1
visible 1
decoration
}
itemDef
{
name "button_unfocus"
type ITEM_TYPE_BUTTON
style WINDOW_STYLE_EMPTY
rect 265 365 110 50
textalign ITEM_ALIGN_CENTER
visible 1
onFocus
{
hide focus_window;
show unfocus_window;
}
}
itemDef
{
name "button_reg"
text "text here"
type ITEM_TYPE_BUTTON
style WINDOW_STYLE_EMPTY
textstyle ITEM_TEXTSTYLE_SHADOWED
rect 275 375 90 30
textalign ITEM_ALIGN_CENTER
textscale GLOBAL_TEXT_SIZE
textalignx 45
textaligny 25
forecolor GLOBAL_UNFOCUSED_ORANGE
visible 1
textfont UI_FONT_NORMAL
action
{
play "mouse_click";
}
onFocus
{
hide unfocus_window;
play "mouse_over";
show focus_window;
}
}
Don't forget to hide focus_window when opening the menu, so, on menuDef:
onOpen
{
hide focus_window;
show unfocus_window;
}
Like the title says, I'm trying to change the background of a menu window onFocus.
I did it successfully by making two windows - unfocus_window and focus_window, with the desired background colors.
Then I used onFocus in the text that is over the window:
onFocus
{
hide unfocus_window;
play "mouse_over";
show focus_window;
}
The only problem I have is how to change the color back "onUnFocus".
How can I do it?
Edit: I'm not sure if there is an easier way, but I'm going to create a button under the window which is slightly bigger, and I'm gonna use onFocus on it.
Edit #2: It works :)
If there is an easier way than this workaround, please let us know.
Here is the code:
itemDef
{
name "unfocus_window"
style WINDOW_STYLE_FILLED
rect 275 375 90 30
backcolor 0.2 0.8 0.2 .3
border 1
bordercolor 1 0.5 0 1
visible 1
decoration
}
itemDef
{
name "focus_window"
style WINDOW_STYLE_FILLED
rect 275 375 90 30
backcolor 1 0.6 0.3 .3
border 1
bordercolor 0 1 0 1
visible 1
decoration
}
itemDef
{
name "button_unfocus"
type ITEM_TYPE_BUTTON
style WINDOW_STYLE_EMPTY
rect 265 365 110 50
textalign ITEM_ALIGN_CENTER
visible 1
onFocus
{
hide focus_window;
show unfocus_window;
}
}
itemDef
{
name "button_reg"
text "text here"
type ITEM_TYPE_BUTTON
style WINDOW_STYLE_EMPTY
textstyle ITEM_TEXTSTYLE_SHADOWED
rect 275 375 90 30
textalign ITEM_ALIGN_CENTER
textscale GLOBAL_TEXT_SIZE
textalignx 45
textaligny 25
forecolor GLOBAL_UNFOCUSED_ORANGE
visible 1
textfont UI_FONT_NORMAL
action
{
play "mouse_click";
}
onFocus
{
hide unfocus_window;
play "mouse_over";
show focus_window;
}
}
Don't forget to hide focus_window when opening the menu, so, on menuDef:
onOpen
{
hide focus_window;
show unfocus_window;
}