| Mirage Source http://miragesource.net/forums/ |
|
| Press enter to start writing http://miragesource.net/forums/viewtopic.php?f=210&t=3893 |
Page 1 of 1 |
| Author: | Ligaman [ Wed Jun 25, 2008 11:39 pm ] |
| Post subject: | Press enter to start writing |
Hi all. I dont know if this allready has been posted but i need a tut on how to write only when Enter is pressed. I am asking this because when i type my key for inventory/spells/movement it also print them up in the writing box. Thanks -ligaman |
|
| Author: | Coke [ Thu Jun 26, 2008 12:15 pm ] |
| Post subject: | Re: Press enter to start writing |
If you have used the tutorial for the Rich text box instead of writing on the screen, just rely on if that rtb is visible or not. On keypresses, if rtbwhatever.visible = true then fishcake else fishcake2 and have your enter keypress as if rtbwhatever.visible = true then rtbwhatever.visible = false else rtbwhatever.visible = true :] |
|
| Author: | Leighland [ Tue Jul 08, 2008 5:15 am ] |
| Post subject: | Re: Press enter to start writing |
If you're using a text box it would probably be just as easy as: Code: Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If txtType.Text = "" Then txtType.SetFocus Else picScreen.SetFocus End If End If Call CheckInput(1, KeyCode, Shift) End Sub Of course, txtType is the name of my text box, so you'll need to make the necessary changes. Anyways, what this will do is check if the enter key was hit. if so, it then checks of there is no text typed into the text box it sets the focus to the text box, allowing you to begin typing. If there is text already in the text box, it sets the focus back to picScreen, "deselecting" the text box, so the user will not be able to type until the text box is cleared. Each time, no matter the outcome, it calls the checkinput sub so it can still do the necessary checks for picking up items etc. It might not work that flawlessly, but try it out, see what happens. Also, I should add that if you wanted something like world of warcraft for instance, where the text box is hidden until enter is pushed, then you would just put that in there as well as an additional check, like fox described above. There's really a million possibilities when it comes to how your players will enter text. This should get you started though. |
|
| Author: | Ligaman [ Tue Jul 08, 2008 7:58 am ] |
| Post subject: | Re: Press enter to start writing |
thanks that worked but i have a problem i had before as well.When i try to type it deletes every letter i type.Some help? |
|
| Author: | Asrrin29 [ Tue Jul 08, 2008 11:58 am ] |
| Post subject: | Re: Press enter to start writing |
make a EnterPressed As Boolean flag. in the HandleKeyPresses Sub/Mod, and a check to see if that flag is true or false. when you hit enter the first time, set it to true, when it is hit again to complete you text, set it to false. as long as EnterPressed = False, HandleKeyPresses won't type out text. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|