is it possible to check command buttons for the focus and change the color of the button with the focus?
Printable View
is it possible to check command buttons for the focus and change the color of the button with the focus?
Simply said:
VB Code:
Private Sub Command1_GotFocus() Command1.BackColor = RGB(255, 0, 0) End Sub
Note that you have to set Command1.Style to 1 in the Form editor (you can't access it at runtime that easy).
thanx. i do have another question though. i've tried this before, but maybe i was doing something wrong. is it possible to use theto call theVB Code:
Private Sub Form_KeyDown()
VB Code:
Private Sub Command1_GotFocus()
i'm trying to make a menu screen on my game, and i would like to make it completely mouse free. (so far, i'm using the mouse to click the command buttons i have in battles)
If you do do that then the Command button won't actually take focus but it will run the code as if it had taken focus. If your wanting to give the button focus I think there is a set focus method ;).Quote:
Originally posted by CapFlea03
thanx. i do have another question though. i've tried this before, but maybe i was doing something wrong. is it possible to use theto call theVB Code:
Private Sub Form_KeyDown()
VB Code:
Private Sub Command1_GotFocus()
i'm trying to make a menu screen on my game, and i would like to make it completely mouse free. (so far, i'm using the mouse to click the command buttons i have in battles)
sorry, i got my questions mixed up. is it possible to push a button on the keyboard to "click" a command button?
You can always write a a & in front in the caption property of a command button. THen there will be a _ under the first letter, and the user can press Alt+The first letter in the name to click that button....
yeah, thats how i moved around in my first game, and even though i told people to hold alt right at the beginning when the game first came up, everybody still got confused. i'm trying to move away from using alt to click a command button if thats possible.
If it is a game you should not use the command buttons at all...use the keyup key down events....tutorual in the FAQ...
i know how do use the key up and key down events, and i've removed command buttons from most of my game, but what i'm trying to do right now is create a menu to show character stats and things. i'd like to have command buttons that change color when they have the focus, and have the player be able to push a set button (key down) which activates the current command button. like i said in an earlier post, i'm trying to get away from using the mouse completely.
Nothing wrong with using command buttons, you can use the tab key to jump between all focusable objects and arrow keys for just for instance buttons..Quote:
If it is a game you should not use the command buttons at all
for instance button?? But the probelm is that the arraw keys are moving the focus, and the click is not autoamticaly fetched by the event...Quote:
Originally posted by kedaman
Nothing wrong with using command buttons, you can use the tab key to jump between all focusable objects and arrow keys for just for instance buttons..
theres a got focus event for that if i remember correctlyQuote:
Originally posted by NoteMe
for instance button?? But the probelm is that the arraw keys are moving the focus, and the click is not autoamticaly fetched by the event...
Quote:
Originally posted by kedaman
theres a got focus event for that if i remember correctly
Yeah but that won't help you much. If you use that, you will still have to write the same code as if you are not using command buttons + some more. Becuase if you lay the buttons now in the order:
Up - Right - down - Left
And you are in the game, then the up arrow will have the focus, and if you then press the down arrow, then the RIGHT button will have the focus. and if oyu press the down button again, then the DOWN button will have the focus, and if you press the down arrow again, then the left button will have the focus.
ah so thats what you meant, but are you suppose to focus them or have the effect of clicking on them by pressing the arrow buttons?
i want them to focus with the arrow keys, and click when the user presses a certain key, which i will designate.
and the order in which they are focused? You could set the focus accordingly I guess if you just subclass the buttons