Announcement

Collapse
No announcement yet.

Hilighted button in GUI; how to get rid of it?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hilighted button in GUI; how to get rid of it?

    Well I've create a basic popup-menu, and it works great. It has several identical buttons going down the left-hand side, and a close button in the upper-right corner. However, when the menu pops up, one of the buttons is "hilighted". It's like when you move your mouse over a button and it lights up, that's what it looks like. But even when I move my mouse over other buttons, they light up just fine, but this one button is ALWAYS hilighted.

    This is very confusing, because the code for the buttons are IDENTICAL. I made one button and just copy and pasted the code for the others, changing only the button's name and caption. THAT'S ALL.

    So I wonder, why would this one seemingly random button always be hilighted? It's always the same one each time. I tried commenting out the code of that button, and just the next button in the list becomes the hilighted one.
    Very, very strange.

    Here's a sample of what my code looks like...

    Code:
    	Begin Object Class=GUIButton Name=Button1
        	Caption="Button 1"
            Hint="First Button"
            WinTop=0.04
            WinLeft=0.04
            WinWidth=0.22
            WinHeight=0.07
            RenderWeight=0.5
            bBoundToParent=True
            bScaleToParent=True
            OnClick=MyMod.ButtonClicked
        End Object
    	buttons[0]=GUIButton'MyMod.MyPopup.Button1'
    
    	Begin Object Class=GUIButton Name=Button2
        	Caption="Button 2"
            Hint="Second Button"
            WinTop=0.04
            WinLeft=0.04
            WinWidth=0.22
            WinHeight=0.07
            RenderWeight=0.5
            bBoundToParent=True
            bScaleToParent=True
            OnClick=MyMod.ButtonClicked
        End Object
    	buttons[1]=GUIButton'MyMod.MyPopup.Button2'
    etc. Like I said, the code for every button is IDENTICAL. It makes no sense one button would be hilighted like this.

    Anybody have any suggestions?

    #2
    its a bug in the code somewhere (probably native). when you disable bFocusOnWatch it casues it. when the menu opens, the first control is always selected. setting bFocusOnWatch=TRUE will probably fix it, but that causes the menu buttons to stay lighted when watched, which looks like the button is still focused.

    its a trade off.

    Comment


      #3
      It didn't work. I tried putting bFocusOnWatch=true in both the menu's defaultproperties as well as inside the button's. But the same **** button still stays hilighted.

      Comment


        #4
        can't you switch the order of your controls so that the first item isn't a button? like if it were a label or something, then the highlighting wouldn't show. or create a dummy button with a size of 0 so it won't show?

        Comment


          #5
          tried that, lol. didnt work for me. but i wasnt using the controls array at all anyway.

          Comment


            #6
            you tried the dummy button too? like you made a fake button that isn't visible as the first button and only one STILL remained highlighted?

            Comment


              #7
              too hacky

              Comment


                #8
                Well here's the thing: It ISN'T the first button that's being hilighted, its like the 7th button. :weird:

                Comment


                  #9
                  ... that's intense. i was just basing the hack on the comment that it was a bug involving the first control. i'll look at it tomorrow...

                  Comment


                    #10
                    is it by chance the first button you create in default properties?

                    is its tab order 0?

                    if no, im stumped

                    try setting bFocusOnWatch to TRUE.

                    Comment


                      #11
                      Originally posted by Bonehed316
                      is it by chance the first button you create in default properties?

                      is its tab order 0?

                      if no, im stumped

                      try setting bFocusOnWatch to TRUE.
                      You obviously didn't read my other posts.

                      All my buttons are in defaultproperties, but where the first one is is irrelevant because it's NOT the one being hilighted; the 7th button is. And I already tried setting bFocusOnWatch to true and it had no effect.

                      Comment


                        #12
                        Try using function SetFocus in Opened delegate.
                        In SetFocus put something like image(that don't have focus), but not background, because it'll become foreground!

                        Comment


                          #13
                          Originally posted by Bonehed316
                          its a bug in the code somewhere (probably native). when you disable bFocusOnWatch it casues it. when the menu opens, the first control is always selected.
                          That isn't a bug. When you open a menu, the first control is supposed to receive focus. If nothing has focus, your page won't receive key events.

                          Comment


                            #14
                            so its not a bug, its a "feature"

                            still, i dont think this is the optimal behavior. windows doesnt automatically highlight the first button on a page, and for good reason. just like when the mouse leaves a control it no longer remains focused. it just doesnt make sense. though im sure there was good reason to leave it like that.

                            ive spent the better part of the last three days creating the menu system for our mod, and while i can say that most of the code is quite nice, that "feature" is definately one of my least favorite. although it is much nicer than uwindows :up:

                            Comment


                              #15
                              Originally posted by Bonehed316
                              windows doesnt automatically highlight the first button on a page, and for good reason. just like when the mouse leaves a control it no longer remains focused.
                              Well, let's clarify what's actually happening. When a GUIPage is opened, the first control (as determined by the TabOrder property) is given focus. The color of a control is determined by its Style, which stores an array of colors corresponding to each MenuState. In this case, the GUIButton's style dictates that it should appear "highlighted" when it has focus (MenuState == MSAT_Focused). There is also a watched state (MSAT_Watched), which generally has a slightly lighter color than the focused state. I'd be intested to find out which MenuState this button is actually getting stuck in.

                              This is essentially the same way that Windows does it. The difference is that Windows doesn't [normally] change the color of a button when it receives focus. However, this is something that would be changed by modifying the GUIButton's style...not by reengineering the way that focus chains work.

                              As for bFocusOnWatch, this should always be false unless your GUIButton's style has been specifically designed for it (such as the case with the main menu's buttons). Otherwise, you're not going to really find any use for it.

                              Comment

                              Working...
                              X