|
-
May 23rd, 2004, 09:25 PM
#1
Thread Starter
Junior Member
command button question
is it possible to check command buttons for the focus and change the color of the button with the focus?
-
May 24th, 2004, 12:15 AM
#2
PowerPoster
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).
-
May 24th, 2004, 09:55 AM
#3
Thread Starter
Junior Member
thanx. i do have another question though. i've tried this before, but maybe i was doing something wrong. is it possible to use the
VB Code:
Private Sub Form_KeyDown()
to call the
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)
-
May 24th, 2004, 09:59 AM
#4
Ex-Super Mod'rater
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 the
VB Code:
Private Sub Form_KeyDown()
to call the
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 .
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
May 24th, 2004, 10:07 PM
#5
Thread Starter
Junior Member
sorry, i got my questions mixed up. is it possible to push a button on the keyboard to "click" a command button?
-
May 25th, 2004, 04:31 AM
#6
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....
-
May 25th, 2004, 08:27 AM
#7
Thread Starter
Junior Member
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.
-
May 25th, 2004, 08:28 AM
#8
If it is a game you should not use the command buttons at all...use the keyup key down events....tutorual in the FAQ...
-
May 25th, 2004, 04:55 PM
#9
Thread Starter
Junior Member
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.
-
May 25th, 2004, 05:25 PM
#10
transcendental analytic
If it is a game you should not use the command buttons at all
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..
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 25th, 2004, 05:27 PM
#11
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..
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...
-
May 26th, 2004, 07:47 PM
#12
transcendental analytic
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...
theres a got focus event for that if i remember correctly
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 27th, 2004, 12:04 AM
#13
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.
-
May 28th, 2004, 03:27 PM
#14
transcendental analytic
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?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2004, 11:14 AM
#15
Thread Starter
Junior Member
i want them to focus with the arrow keys, and click when the user presses a certain key, which i will designate.
-
Jun 1st, 2004, 05:21 PM
#16
transcendental analytic
and the order in which they are focused? You could set the focus accordingly I guess if you just subclass the buttons
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|