curly
Full Member
Posts: 161
|
Post by curly on Jul 11, 2021 5:17:27 GMT -5
Hi Again,
It would be really useful to have a pop-up programmable number pad with numbers 0-9, decimal point, N/A, N/V, and a finish or OK key.
I can't find anything like it on the forum, does anyone know if something like it already exists?
i ALSO DIDN'T KNOW MESSAGES COULD BE SENT TO INDIVIDUALS - SOMEONE LEFT ME A MESSAGE I HAVE ONLY JUST FOUND IT AND ANSWERED
Kind regards, David
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 12, 2021 4:28:29 GMT -5
Hi Walt,
It's not for calculations. The user will need to enter data into textboxes, typically numbers such as 999, 0.42 etc, but also N/A or N?V, and I want to make it as simple as possible. I'm afraid my nature is that I am always looking to push boundaries. My very loose thinking is that when clicking into a textbox, he can touch maybe a button to get the keypad up, and bang his number out on the keypad? The application will be on a tablet. I don't know if it's possible?
Kind regards, David
|
|
|
Post by Rod on Jul 12, 2021 12:28:00 GMT -5
Ok, here is a very quick and dirty example of the technique. Touch your tablet screen.
' nomainwin WindowWidth = 162 WindowHeight = 162 graphicbox #1.gb 0,0,162,162 open "Input" for window_popup as #1 #1 "trapclose [quit]"
k$="789N456Y123?00.Q" k=1 #1.gb "down ; backcolor darkgray ; color white" for y= 0 to 120 step 40 for x= 0 to 120 step 40 #1.gb "place ";x;" ";y;" ; boxfilled ";x+40;" ";y+40 #1.gb "place ";x+15;" ";y+25 #1.gb "\";mid$(k$,k,1) k=k+1 next next #1.gb "flush seg"
'start event tracking #1.gb "when leftButtonUp [gettouch]" #1.gb "setfocus" wait
[gettouch] x=int(MouseX/40) y=int(MouseY/40) i$=mid$(k$,4*y+x+1,1) if i$="Q" then goto [quit] print i$ wait
[quit] close #1 end
|
|
|
Post by Rod on Jul 12, 2021 13:28:01 GMT -5
We can easily create our own keypad, here is the same rough demo but now interacting with two textboxes. Touch the < button to popup the keypad. Touch the next < button beside the textbox to move on. You can close the keypad or just leave it on and allow the next input box < to be clicked. Play and tell us what needs fixed. The keypad probably needs to be moveable. It currently pops up next to the initiating keypress. I have included a delete < key as well as N/A, N?V and Quit
nomainwin textbox #t.txt1, 20, 40, 200, 25 button #t.tb1, "<",[tb1input],UL,240, 40, 20, 25 textbox #t.txt2, 20, 70, 200, 25 button #t.tb2, "<",[tb2input],UL,240, 70, 20, 25 WindowWidth = 350 : WindowHeight = 190 open "Simple text box use" for dialog as #t #t "trapclose [quit]" wait
[tb1input] tbh$="#t.txt1" gosub [touchinput] wait
[tb2input] tbh$="#t.txt2" gosub [touchinput] wait
[touchinput] if tbt=0 then nomainwin WindowWidth = 162 WindowHeight = 162 graphicbox #1.gb 0,0,162,162 open "Input" for window_popup as #1 #1 "trapclose [close]"
k$=" 7 , 8 , 9 ,N/A, 4 , 5 , 6 ,N?V, 1 , 2 , 3 , < , 0 , 0 , . , Q " k=1 #1.gb "down ; backcolor darkgray ; color white" for y= 0 to 120 step 40 for x= 0 to 120 step 40 #1.gb "place ";x;" ";y;" ; boxfilled ";x+40;" ";y+40 #1.gb "place ";x+12;" ";y+25 #1.gb "\";word$(k$,k,",") k=k+1 next next #1.gb "flush seg"
'start event tracking #1.gb "when leftButtonUp [gettouch]" tbt=1 end if #1.gb "setfocus" wait
[gettouch] x=int(MouseX/40) y=int(MouseY/40) i$=word$(k$,4*y+x+1,",") if i$=" Q " then goto [close] if i$=" < " then c$=left$(c$,len(c$)-1) #tbh$ "!contents? c$" if i$=" < " then c$=left$(c$,len(c$)-1) #tbh$ c$ else #tbh$ c$+trim$(i$) end if wait
[close] tbt=0 close #1 wait
[quit] if tbt then close #1 close #t end
|
|
|
Post by Walt Decker on Jul 13, 2021 21:39:13 GMT -5
Here is a complete app:
' WS.OVERLAPPED = HEXDEC("&H00000000") WS.VISIBLE = HEXDEC("&H10000000") WS.CLIPSIBLINGS = HEXDEC("&H04000000") WS.CLIPCHILDREN = HEXDEC("&H02000000") WS.CAPTION = HEXDEC("&H00C00000") WS.SYSMENU = HEXDEC("&H00080000") WS.THICKFRAME = HEXDEC("&H00040000") WS.GROUP = HEXDEC("&H00020000") WS.TABSTOP = HEXDEC("&H00010000")
WS.MINIMIZEBOX = HEXDEC("&H00020000") WS.MAXIMIZEBOX = HEXDEC("&H00010000")
WS.OVERLAPPEDWINDOW = (WS.OVERLAPPED _ OR WS.CAPTION _ OR WS.SYSMENU _ OR WS.THICKFRAME _ OR WS.MINIMIZEBOX _ OR WS.MAXIMIZEBOX)
WS.EX.DLGMODALFRAME = HEXDEC("&H00000001") WS.EX.STATICEDGE = HEXDEC("&H00020000") WS.EX.TOPMOST = HEXDEC("&H00000008") WS.EX.TOOLWINDOW = HEXDEC("&H00000080")
GWL.WNDPROC = -4 GWL.ID = -12 GWL.USERDATA = -21
OPEN "User32.dll" FOR DLL AS #USER
GLOBAL PadHndl, _ LstFocus
GLOBAL VOLTS, _ AMPS, _ REST, _ PAD GLOBAL Ubnd
Ubnd = 2
DIM CtlNames$(2)
STYLEBITS #ELEC.VOLTS, WS.TABSTOP OR WS.GROUP, 0, WS.EX.STATICEDGE OR WS.EX.DLGMODALFRAME, 0 TEXTBOX #ELEC.VOLTS, 5, 5, 50, 25
STYLEBITS #ELEC.AMPS, WS.TABSTOP, 0, WS.EX.STATICEDGE OR WS.EX.DLGMODALFRAME, 0 TEXTBOX #ELEC.AMPS, 60, 5, 50, 25
STYLEBITS #ELEC.REST, WS.TABSTOP, 0, WS.EX.STATICEDGE OR WS.EX.DLGMODALFRAME, 0 TEXTBOX #ELEC.REST, 115, 5, 50, 25
STYLEBITS #ELEC.PAD, WS.TABSTOP OR WS.GROUP, 0, WS.EX.DLGMODALFRAME, 0 BUTTON #ELEC.PAD, "NUM PAD", OPEN.PAD, UL, 5, 35, 68, 25
STYLEBITS #ELEC.OK, WS.TABSTOP, 0, WS.EX.DLGMODALFRAME, 0 BUTTON #ELEC.OK, "APPLY", ADD.VAL, UL, 115, 35, 68, 25
OPEN "ELEC" FOR WINDOW AS #ELEC PRINT #ELEC.VOLTS, "!setfocus" PRINT #ELEC, "TRAPCLOSE DEMO.DONE"
CtlHndl = HWND(#ELEC.VOLTS) LstFocus = CtlHndl
CALLDLL #USER, "GetDlgCtrlID", CtlHndl AS ULONG, VOLTS AS LONG CtlHndl = HWND(#ELEC.AMPS) CALLDLL #USER, "GetDlgCtrlID", CtlHndl AS ULONG, AMPS AS LONG CtlHndl = HWND(#ELEC.REST) CALLDLL #USER, "GetDlgCtrlID", CtlHndl AS ULONG, REST AS LONG
CtlNames$(0) = "#ELEC.VOLTS" CtlNames$(1) = "#ELEC.AMPS" CtlNames$(2) = "#ELEC.REST"
WAIT
'---------------------------------------------------------- '----------------------------------------------------------
SUB DEMO.DONE ElecHndl$
IF PadHndl THEN CLOSE #PAD END IF
CLOSE #USER CLOSE #ELEC END
END SUB
'---------------------------------------------------------- '----------------------------------------------------------
SUB ADD.VAL BtnHndl$
AryPos = 0 CtlId = 0
CtlStr$ = "" Tmp$ = ""
CALLDLL #USER, "GetDlgCtrlID", LstFocus AS ULONG, CtlId AS LONG AryPos = CtlId - VOLTS + 1
IF AryPos > Ubnd THEN EXIT SUB CtlStr$ = CtlNames$(AryPos) LstFocus = HWND(#CtlStr$)
END SUB
'---------------------------------------------------------- '----------------------------------------------------------
SUB OPEN.PAD BtnHndl$
IF PadHndl THEN EXIT SUB
WS.OVERLAPPED = HEXDEC("&H00000000") WS.VISIBLE = HEXDEC("&H10000000") WS.CLIPSIBLINGS = HEXDEC("&H04000000") WS.CLIPCHILDREN = HEXDEC("&H02000000") WS.CAPTION = HEXDEC("&H00C00000") WS.SYSMENU = HEXDEC("&H00080000") WS.THICKFRAME = HEXDEC("&H00040000") WS.GROUP = HEXDEC("&H00020000") WS.TABSTOP = HEXDEC("&H00010000")
WS.MINIMIZEBOX = HEXDEC("&H00020000") WS.MAXIMIZEBOX = HEXDEC("&H00010000")
WS.OVERLAPPEDWINDOW = (WS.OVERLAPPED _ OR WS.CAPTION _ OR WS.SYSMENU _ OR WS.THICKFRAME _ OR WS.MINIMIZEBOX _ OR WS.MAXIMIZEBOX)
WS.EX.DLGMODALFRAME = HEXDEC("&H00000001") WS.EX.STATICEDGE = HEXDEC("&H00020000") WS.EX.TOPMOST = HEXDEC("&H00000008") WS.EX.TOOLWINDOW = HEXDEC("&H00000080")
GWL.STYLE = -16 GWL.EXSTYLE = -20
STRUCT tRect, _ X AS LONG, _ Y AS LONG, _ X1 AS LONG, _ Y1 AS LONG
CtlHndl = 0
STYLEBITS #PAD.0, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.1, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.P, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.2, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.3, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.NV, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.4, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.5, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.NA, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.6, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.7, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.8, 0, 0, WS.EX.DLGMODALFRAME, 0 STYLEBITS #PAD.9, 0, 0, WS.EX.DLGMODALFRAME, 0
BUTTON #PAD.0, "0", SET.TXT, UL, 5, 5, 20, 25 BUTTON #PAD.1, "1", SET.TXT, UL, 30, 5, 20, 25 BUTTON #PAD.P, ".", SET.TXT, UL, 55, 5, 30, 25 BUTTON #PAD.2, "2", SET.TXT, UL, 5, 35, 20, 25 BUTTON #PAD.3, "3", SET.TXT, UL, 30, 35, 20, 25 BUTTON #PAD.NV, "NV", SET.TXT, UL, 55, 35, 30, 25 BUTTON #PAD.4, "4", SET.TXT, UL, 5, 65, 20, 25 BUTTON #PAD.5, "5", SET.TXT, UL, 30, 65, 20, 25 BUTTON #PAD.NA, "NA", SET.TXT, UL, 55, 65, 30, 25 BUTTON #PAD.6, "6", SET.TXT, UL, 5, 95, 20, 25 BUTTON #PAD.7, "7", SET.TXT, UL, 30, 95, 20, 25 BUTTON #PAD.8, "8", SET.TXT, UL, 5, 125, 20, 25 BUTTON #PAD.9, "9", SET.TXT, UL, 30, 125, 20, 25
CtlHndl = HWND(#ELEC.PAD) CALLDLL #USER, "GetWindowRect", CtlHndl AS ULONG, tRect AS STRUCT, RetVal AS VOID
UpperLeftX = tRect.X1.struct - 5 UpperLeftY = tRect.Y.struct + tRect.Y1.struct - tRect.Y.struct + 5 WindowWidth = 100 WindowHeight = 190
STYLEBITS #PAD, WS.CAPTION OR WS.CLIPCHILDREN OR WS.SYSMENU, _ WS.OVERLAPPEDWINDOW, WS.EX.TOOLWINDOW OR WS.EX.TOPMOST, 0 OPEN "NUM PAD" FOR WINDOW AS #PAD PRINT #PAD, "TRAPCLOSE [CLOSE.PAD]" PadHndl = 1 WAIT
[CLOSE.PAD] CLOSE #PAD
PadHndl = 0 END SUB
'--------------------------------------------------------------------- '---------------------------------------------------------------------
SUB SET.TXT BtnHndl$
BtnHndl = 0 CtlId = 0 AryPos = 0
TxtIn$ = "" TxtOut$ = "" Nam$ = ""
BtnHndl = HWND(#BtnHndl$)
CALLDLL #USER, "GetDlgCtrlID", LstFocus AS ULONG, CtlId AS LONG
FOR I = VOLTS TO REST IF CtlId = I THEN CALLDLL #USER, "GetWindowTextLengthA", BtnHndl AS ULONG, TxtLen AS LONG, TxtIn$ = SPACE$(TxtLen) TxtLen = TxtLen + 1 CALLDLL #USER, "GetWindowTextA", BtnHndl AS ULONG, TxtIn$ AS PTR, TxtLen AS LONG, TxtLen AS LONG AryPos = CtlId - VOLTS Nam$ = CtlNames$(AryPos) PRINT #Nam$, "!contents? TxtOut$" TxtOut$ = TxtOut$ + TxtIn$ PRINT #Nam$, TxtOut$ END IF NEXT I
END SUB '
Personally, if a tablet has a keyboard I think it would be faster to type in the data.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 14, 2021 7:58:32 GMT -5
Hi Rod, This is (I think) exactly what I hoped for. I've read up, and now learnt about word$ and trim$, very clever... but I'm struggling to see what the backslash is for in this line, #1.gb "\";word$(k$,k,",") I've played with this a bit, and most of my textboxes can be filled using the keypad, especially if I add another row of 3.
To clarify my understanding, 1. a button is clicked 2. the subrouting associated with the button assigns the handle of the relevant textbox to a temporary variable, and causes the keypad to be created. (tbt prevents it from crashing if an attempt is made to open the keypad when it is already open?) I didn't realise you could use a variable as a handle! 3. The location of the mouse pointer is monitored to select a value on a key when the left mouse button is released. 4. Each key press is added to the total until we click into another textbox or close the keypad.
When I'm filling the textboxes, rather than having a wait at the end of each section, I use a goto to a routing that checks the boxes, makes boxes and buttons visible or not and then waits. The boxes are filled either by tabbing through them in order, or by using various pre-fill buttons that fill several boxes. If I monitored the right mouse position all the time it is waiting, I am hoping I can detect which textbox the mouse is in when the right mouse button is clicked, and open the keypad?
I will give it a try on a couple of textboxes to see if it works.
Thanks again
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 14, 2021 8:23:42 GMT -5
Hi All, Just to clarify, I'm in the UK, and although my English is not the same as US English, I'm not German. N/A means Not Applicable, N/V meens Not Verified or Not Validated, LIM means a Limitation, i.e. it was agreed with the client that something will be omitted from the inspection, or it is an Operational Limitation where access to an area was not possible etc. I am guessing (maybe hoping!) a screen touch on a tablet is the equivalent of a left mouse click?, and hope there is something that replicates a right mouse click?
|
|