Results 1 to 4 of 4

Thread: Menus - change window background onFocus

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts

    Menus - change window background onFocus

    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:
    Code:
    			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:
    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:
    Code:
    		onOpen 
    		{
    			hide focus_window;
    			show unfocus_window;
    		}
    Last edited by guiismiti; 29th March 2017 at 18:43.
    set logfile 2

  2. The Following User Says Thank You to guiismiti For This Useful Post:

    kung foo man (29th March 2017)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •