I am looking for a plugin or code that will allow me to create a textbox that has typeahead features when the user presses certain keys eg # @ $ in the same way you see on Twitter and other social media sites where a popup is shown to select a user or project or group etc. It needs to work in the desktop across Windows and Mac. It also needs to be able to provide a list of tags that were used from the popup.
If this is not available, could people PM me so we can have a conversation for custom development.
[code]Sub TextChange() Handles TextChange
Dim LastTypedCharacter As String
LastTypedCharacter = Right(TextArea1.Text,1)
Select Case LastTypedCharacter
Case “#”
'check if menu is already there
'IsContextMenuShown = Window property
If Not IsContextMenuShown Then
IsContextMenuShown = True
Dim base As New MenuItem
// Add some items
base.Append( New MenuItem("Project Strawberry"))
base.Append( New MenuItem("Project Salami"))
base.Append( New MenuItem("Project Pinguin"))
Dim hitItem As MenuItem
hitItem = base.PopUp
'You could give desired X and Y coordinates as parameter here, but is difficult to obtain (base.Popup(123,237))
IsContextMenuShown = False
TextArea1.Text = TextArea1.Text + hitItem.Text
End If
Case “@”
If Not IsContextMenuShown Then
IsContextMenuShown = True
Dim base As New MenuItem
// Add some items
base.Append( New MenuItem(“User Tom”))
base.Append( New MenuItem(“User Hank”))
base.Append( New MenuItem(“User Dililah”))
Dim hitItem As MenuItem
hitItem = base.PopUp
IsContextMenuShown = False
TextArea1.Text = TextArea1.Text + hitItem.Text
End If
End Select
End Sub
[/code]
The X,Y parameters should indicate the position of the contextual menu but I could’t figure out how to get these. Now the popup appears where the mouse is…
Sub TextChange()Handles TextChange
Dim LastTypedCharacter As String = Right(TextArea1.Text, 1)
If Not IsContextMenuShown Then
IsContextMenuShown = True
Dim base As New MenuItem
Select Case LastTypedCharacter
Case "#"
base.Append( New MenuItem("Project Strawberry"))
base.Append( New MenuItem("Project Salami"))
base.Append(New MenuItem("Project Pinguin"))
Case "@"
base.Append( New MenuItem("User Tom"))
base.Append( New MenuItem("User Hank"))
base.Append(New MenuItem("User Dililah"))
End Select
Dim hitItem As MenuItem
hitItem = base.PopUp
IsContextMenuShown = False
If hitItem <> Nil Then TextArea1.Text = TextArea1.Text + hitItem.Text
End If
End Sub
FYI… The end result is a lot more complex, although the above code snippets show a proof of concept.
His requirements are that the hotkeys and associated lists NOT be hardcoded, and the the menu contains option images.
I have created a custom control that meets all of his requirements… if I can just get a stable method to locate the XY of the SELSTART on the screen. It works until you scroll
this is the code i have in my custom textarea control. i have 2 field in the share db called TypeAheadHashSign and TypeAheadAtSign and user can enter the list of string in a preference screen. what i also do is remove the @ or the # after selecting the text
If TypeAheadYN Then
//********************
// TypeAheadYN??
//********************
Dim LastTypedCharacter As String
LastTypedCharacter = Right(Text, 1)
Dim vMC As String
Select Case LastTypedCharacter
Case "#"
vMC = sdictShare.value("TypeAheadHashSign").Textvalue
Case "@"
vMC = sdictShare.value("TypeAheadAtSign").Textvalue
End Select
If LEN(vMC) <> 0 Then
Dim base As New MenuItem
Dim i As Integer
Dim vCnt As Integer
Dim vMCLine() As String
Dim aLine As String
vMC = REPLACEALL(vMC, EndOfLine.Windows, "|")
vMC = REPLACEALL(vMC, EndOfLine.Macintosh, "|")
vMC = REPLACEALL(vMC, EndOfLine.UNIX, "|")
vMCLine = Split(vMC, "|")
vCnt = ubound(vMCLine)
For i = 0 To vCnt
aLine = Trim(vMCLine(i))
base.Append(New MenuItem(aLine))
Next
Dim hitItem As MenuItem
hitItem = base.PopUp
If hititem <> Nil Then Text = left(Text, LEN(Text) - 1) + hitItem.Text
End If
End If