Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Press enter to start writing
#1
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
Reply
#2
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

:]
Reply
#3
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.
Reply
#4
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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)