Results 1 to 4 of 4

Thread: Menus - change window background onFocus

  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 19:43.
    set logfile 2

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

    kung foo man (29th March 2017)

  3. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    You could also do it like this:

    PHP Code:
                mouseEnter
                
    {
                    
    setItemColor "some_item" forecolor 1 1 1 1
                
    }
                
    mouseExit
                
    {
                    
    setItemColor "some_item" forecolor 1 1 1 0
                

    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  4. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (29th March 2017)

  5. #3
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Thank you izno.
    I got it working like this:
    PHP Code:
                mouseEnter
                
    {
                    
    setItemColor "window_name" backcolor 1 0.6 0.3 .3;
                    
    setItemColor "window_name" bordercolor 0 1 0 1;
                }
                
    mouseExit
                
    {
                    
    setItemColor "window_name" backcolor 0.2 0.8 0.2 .3;
                    
    setItemColor "window_name" bordercolor 1 0.5 0 1;
                } 
    set logfile 2

  6. #4
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Dont mind me, just silently cursing at myself for adding borders to my menus manually for years now.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (30th 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
  •