SyntaxBomb - Indie Coders
Languages & Coding => Blitz Code Archives => BlitzPlus Gui => Topic started by: BlitzBot on June 29, 2017, 00:28:40
Title : GadGetKey_TextArea
Author : ShadowTurtle
Posted : 1+ years ago
Description : Hi.
Here is a small sample:
...
While Programm
...
A$ = GadGetKey_TextArea(MyTextArea)
If A$ = "j" Then RuntimeError "You pressed 'j' in TextArea"
Wend
Code :
wnd = CreateWindow("GadGet Key - Test", 10, 10, 400, 400, 0, 1)
butn1 = CreateButton("Exit.", 2, 2, 100, 30, wnd)
textlabel = CreateLabel("Please press a key in textarea.", 120, 2, 200, 20, wnd)
textarea = CreateTextArea(2, 40, 388, 300, wnd)
Programm = 1
While Programm
MyEvent = WaitEvent()
If EventSource() = butn1 Then Programm = 0
If EventSource() = textarea Then
I$ = GadGetKey_TextArea$(textarea)
SetGadgetText textlabel, "You have lost pressed: " + I$
End If
Wend
Type ScanGadGetKey
Field GadGetHandle
Field LostGadGetText$
Field NewGadGetText$
Field GadGetType
End Type
Function GadGetKey_TextArea$(objhandle)
Local SGGK.ScanGadGetKey
SGGK = Null
For ScanGadGetKey.ScanGadGetKey = Each ScanGadGetKey
If ScanGadGetKeyGadGetHandle = objhandle Then SGGK = ScanGadGetKey
Next
If SGGK = Null Then
SGGK.ScanGadGetKey = New ScanGadGetKey
SGGKGadGetHandle = objhandle
SGGKLostGadGetText$ = TextAreaText$(objhandle)
SGGKGadGetType = 0
Return GadGetKey_TextArea$(objhandle)
Else
SGGKLostGadGetText$ = SGGKNewGadGetText$
SGGKNewGadGetText$ = TextAreaText$(SGGKGadGetHandle)
For GGKT = 1 To Len(SGGKNewGadGetText$)
If Not (Mid$(SGGKNewGadGetText$, GGKT, 1) = Mid$(SGGKLostGadGetText$, GGKT, 1)) Then
Return Mid$(SGGKNewGadGetText$, GGKT, 1)
End If
Next
End If
End Function
Comments :
danielos(Posted 1+ years ago)
could you do this also for mouseclicks and keys like [CTRL] and [Enter] ?
ShadowTurtle(Posted 1+ years ago)
This isnt possible without winapi, i think. The solution on top uses only blitzplus commands. No winapi-userlib is required.