Mirage Source
[Feature] Open/Close ChatBox - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Source Code Development (https://mirage-engine.uk/forums/forumdisplay.php?fid=51)
+----- Forum: Mirage Source 4 (Visual Basic 6) (https://mirage-engine.uk/forums/forumdisplay.php?fid=44)
+------ Forum: Tutorials (https://mirage-engine.uk/forums/forumdisplay.php?fid=13)
+------ Thread: [Feature] Open/Close ChatBox (/showthread.php?tid=2157)



[Feature] Open/Close ChatBox - Mattyw - 21-09-2008

Difficulty: 0/5 - Very easy to add/use.
Functionality: Made for MS4, good for if TextBox is on the GameScreen(kind of).

Go into frmMirage, & look for "Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)", then add this in:

Code:
If KeyCode = vbKeyReturn Then
        If txtChat.Visible = False Then
            txtChat.Visible = True
            txtMyChat.Visible = True
            SetFocusOnChat
        Else
            If txtMyChat.Text  vbNullString Then
                txtChat.Visible = True
                txtMyChat.Visible = True
                Exit Sub
            End If
            txtChat.Visible = False
            txtMyChat.Visible = False
        End If
    End If

It's amde so when you press Enter, it opens. If you press enter with a message, ChatBox stays open, if you press Enter without a message it closes.

ENJOY!


Re: [Feature] Open/Close ChatBox - GIAKEN - 21-09-2008

Would this interfere with pressing enter to send a message?


Re: [Feature] Open/Close ChatBox - Jacob - 21-09-2008

Code:
If KeyCode = vbKeyReturn Then
            txtChat.Visible = not txtChat.Visible
            txtMyChat.Visible = not txtMyChat.Visible        
    End If



Re: [Feature] Open/Close ChatBox - GIAKEN - 21-09-2008

Code:
If KeyCode = vbKeyReturn Then
        txtChat.Visible = Not txtChat.Visible
        txtMyChat.Visible = Not txtMyChat.Visible
        KeyCode = 0
    End If



Re: [Feature] Open/Close ChatBox - Nean - 21-09-2008

Code:
' lol I added a comment
  If KeyCode = vbKeyReturn Then
        txtChat.Visible = Not txtChat.Visible
        txtMyChat.Visible = Not txtMyChat.Visible
        KeyCode = 0
    End If



Re: [Feature] Open/Close ChatBox - Anthony - 21-09-2008

How about adding a frmMirage.Height = blah blah so that it shrinks/enlarges the form when you open/close it.


Re: [Feature] Open/Close ChatBox - Mattyw - 21-09-2008

I have it ontop of my GameScreen, so I'll leave for the PUBLIC to modify. =-p

EDIT: Updated:

Code:
If KeyCode = vbKeyReturn Then
        If txtText.Visible = False Then
            txtText.Visible = True
            txtChat.Visible = True
            txtMyChat.Visible = True
            SetFocusOnChat
        Else
            If txtMyChat.Text  vbNullString Then
                txtText.Visible = True
                txtChat.Visible = True
                txtMyChat.Visible = True
                Exit Sub
            End If
            txtText.Visible = False
            txtChat.Visible = False
            txtMyChat.Visible = False
        End If
    End If

If you entered something, ChatBox stays open, if you entered nothing, it closes.


Re: [Feature] Open/Close ChatBox - skillzalot - 22-09-2008

I don't know if it was your code or mine but every time txt.Text showed up I got Variable not defined so I changed all the txt.Text to txt.Chat and it installed properly so My code looks like this
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Call CheckInput(1, KeyCode, Shift)
    If KeyCode = vbKeyF1 Then
    frmAdminPanel.Visible = True
    End If
    If KeyCode = vbKeyReturn Then
        If txtChat.Visible = False Then
            txtChat.Visible = True
            txtChat.Visible = True
            txtMyChat.Visible = True
            SetFocusOnChat
        Else
            If txtMyChat.Text  vbNullString Then
                txtChat.Visible = True
                txtChat.Visible = True
                txtMyChat.Visible = True
                Exit Sub
            End If
            txtChat.Visible = False
            txtChat.Visible = False
            txtMyChat.Visible = False
        End If
    End If
End Sub
That is my whole Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


Re: [Feature] Open/Close ChatBox - Mattyw - 22-09-2008

skillzalot Wrote:I don't know if it was your code or mine but every time txt.Text showed up I got Variable not defined so I changed all the txt.Text to txt.Chat and it installed properly so My code looks like this
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Call CheckInput(1, KeyCode, Shift)
    If KeyCode = vbKeyF1 Then
    frmAdminPanel.Visible = True
    End If
    If KeyCode = vbKeyReturn Then
        If txtChat.Visible = False Then
            txtChat.Visible = True
            txtChat.Visible = True
            txtMyChat.Visible = True
            SetFocusOnChat
        Else
            If txtMyChat.Text  vbNullString Then
                txtChat.Visible = True
                txtChat.Visible = True
                txtMyChat.Visible = True
                Exit Sub
            End If
            txtChat.Visible = False
            txtChat.Visible = False
            txtMyChat.Visible = False
        End If
    End If
End Sub
That is my whole Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Change/remove txtText, forgot to remove from tut, I used that, but removed & changed with a Dropdown list.


Re: [Feature] Open/Close ChatBox - Clu - 22-09-2008

wouldnt this interfere with enter to pick up items? (assuming enter is pick up items)


Re: [Feature] Open/Close ChatBox - Mattyw - 22-09-2008

Clu Wrote:wouldnt this interfere with enter to pick up items? (assuming enter is pick up items)

Could, it's why I changed my Pickup to SpaceBar. =-p


Re: [Feature] Open/Close ChatBox - Acruno - 17-02-2009

Apologies for the necro but I had a look at this and it doesn't work anymore.
In HandleKeyPresses
Code:
If LenB(ChatText) = 0 Then

change that little bit to
Code:
If LenB(ChatText) = 0 Then
        If KeyAscii = vbKeyReturn Then
            If frmMirage.txtChat.Visible = True Then
                frmMirage.txtChat.Visible = False
                frmMirage.txtMyChat.Visible = False
            Else
                frmMirage.txtMyChat.Visible = True
                frmMirage.txtChat.Visible = True
                SetFocusOnChat
            End If
            Exit Sub
        End If
    End If