curly
Full Member
Posts: 161
|
Post by curly on Jul 14, 2021 8:51:28 GMT -5
IS THERE AN EASIER WAY THAN MOUSEX AND MOUSEY TO TO IDENTIFY THE TEXTBOX I CLICK IN?
I have a lot of textboxes!
|
|
|
Post by Walt Decker on Jul 14, 2021 9:27:56 GMT -5
The code I presented is easy to MAINTAIN and expand. There is no mousex/y involved other than touching the screen. There are no character manipulations involved and it requires very little memory since most of it takes advantage of the MS Windows system. Each button knows exactly where to place the data.
|
|
|
Post by Rod on Jul 14, 2021 9:48:33 GMT -5
It is getting pretty complex but it is all doable. What we don’t get from Liberty is a change of focus event. So to know that you have a change of focus (change of text box) you would need to use an API call to getfocus(). By remembering where you are you can compare the handle returned and know whether you are in a new text box or not. If you are, pop up the keypad input and direct input to the new handle.
This probably fits your strategy as your go to would check all that you do now but also check if the focus has changed.
The \ is a graphics command that must precede text drawn in a graphic box. So it was just drawing the keypad numbers.
Building an example of what you are doing with just a couple of text boxes is a good idea and will get folks focused on solutions that fit with your strategy.
|
|
|
Post by Rod on Jul 14, 2021 9:51:31 GMT -5
I have a vague recollection that right click is press and hold release but you will need to experiment. Touch rarely introduces new events, you just need to know what type of touch to generate the event you need.
|
|
|
Post by Rod on Jul 14, 2021 10:11:40 GMT -5
As Walt suggests you don’t have to use graphics, you can just use buttons and program a bunch of handlers. You will still need to manage what text box you are targeting so getfocus() will still probably be needed.
|
|
|
Post by Brandon Parker on Jul 14, 2021 15:15:09 GMT -5
You would not necessarily even need multiple handlers either. You could set them up with very specific handle names and then parse out the handle sent to the handler subroutine to extract exactly which button was pressed.
I'll make an example later if I get the time.
{:0)
Brandon Parker
|
|
|
Post by Brandon Parker on Jul 14, 2021 21:21:34 GMT -5
Here is an example of what I was talking about doing.
NoMainWin
WindowWidth = 200 WindowHeight = 225
Button #Test.btn1, "1", btnHandler, UL, 5, 5, 30, 25 Button #Test.btn2, "2", btnHandler, UL, 40, 5, 30, 25 Button #Test.btn3, "3", btnHandler, UL, 75, 5, 30, 25 Button #Test.btn4, "4", btnHandler, UL, 5, 35, 30, 25 Button #Test.btn5, "5", btnHandler, UL, 40, 35, 30, 25 Button #Test.btn6, "6", btnHandler, UL, 75, 35, 30, 25 Button #Test.btn7, "7", btnHandler, UL, 5, 65, 30, 25 Button #Test.btn8, "8", btnHandler, UL, 40, 65, 30, 25 Button #Test.btn9, "9", btnHandler, UL, 75, 65, 30, 25 Button #Test.btnNA, "N/A", btnHandler, UL, 5, 95, 30, 25 Button #Test.btn0, "0", btnHandler, UL, 40, 95, 30, 25 Button #Test.btnNV, "N/V", btnHandler, UL, 75, 95, 30, 25 Button #Test.btnOK, "OK", btnOK, UL, 40, 125, 30, 25 TextBox #Test.txtData, 5, 155, 100, 25 Open "Test" For Window As #Test #Test "TrapClose Quit" Wait
Sub Quit handle$ Close #handle$ End End Sub
Sub btnHandler handle$ handle$ = After$(Word$(handle$, 2, "."), "btn") If (Len(handle$) > 1) Then handle$ = Mid$(handle$, 1, 1);"/";Mid$(handle$, 2, 2) #Test.txtData handle$ End Sub
Sub btnOK handle$ Notice "Do something here!" End Sub
{:0)
Brandon Parker
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 15, 2021 6:42:06 GMT -5
Hi again,
I don't think I explained myself very clearly. Rod's keypad is great, and I can use that by adding a button next to each relavent textbox. The issue is that I have a lot of textboxes, and they are quite close together, and there's not a huge amount of space to add buttons. However, my thinking, trying to push boundaries again, is what would be really really great, is to maybe left click into a texbox, but then right click to call up the keypad.
As I already use a number of buttons that need to be shown and hidden according to varioua factors, I avoid using a general wait command dotted around in the 'populate a circuit' section, and instead use a 'goto' to a routine that carries out checks, switches buttons on and off finishing with a wait for the next event. If I can use a 'RightButtonUp' command in a textbox in a normal window, then I can use it in that routine everytime to check which textbox I am in everytime a wait command would normally be used, and call up Rod's keypad. That would be purrrrrfect. My last reply was to see if there was a more simple way to identify which textbox I had clicked into?
Rod, if I call the keypad close to the right hand edge, will it disappear off the screen?
Brandon, Thank you very much, but I have already modified Rod's code slightly and I have it running on just one textbox so far. I am trying to avoid changing and realigning the textboxes, so will try using 'RightButtonUp' on another textbox to see if that works.
|
|
|
Post by tsh73 on Jul 15, 2021 7:31:32 GMT -5
I suggest a hotkey You work with a textbox then you press a hotkey (say F9), LB checks current text editor, opens keypad and puts results in that texteditor. So you don't need any more screen estate
(said that I probably not verced enough to do that)
|
|
|
Post by Brandon Parker on Jul 15, 2021 9:12:52 GMT -5
I think there might be some overcomplicating occurring with the GUI. Check your personal messages again and let's connect.
{:0)
Brandon Parker
|
|
|
Post by Rod on Jul 15, 2021 9:14:10 GMT -5
Ok think tablet and no keyboard. So no hot key. But all is not lost because one button could pop up the keypad. We need to press something on the screen if it is a tablet. Either that or the keypad opens automatically when an input text box is selected or the focus changes.
One single permanent button to pop up the keypad is an option. With API we can detect which text box has focus getfocus(). With API we can move the keypad movewindow()
But there are 100 solutions, need to see a working example of an input screen to offer best advice.
|
|
|
Post by Rod on Jul 15, 2021 9:20:48 GMT -5
Brandon’s code is just as effective as my graphicbox solution. But it still leaves the issue of how / when to open the pop up and how to know what text box to act on.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 15, 2021 13:44:14 GMT -5
Hi again, as you all are aware, trying to use mousex and y in a normal window doesn't work, so I will present Rod's solution using a dedicated button for a couple of textboxes to get some feedback.
Pushing boundaries again, I don't suppose a graphic box will accept commands when it's hidden? I am printing text to textboxes when they are hidden, and the text is visible when I unhide them? My thinking is if the graphic box is an identical size to my window, then mousex and mousey will be the same for both? It's really good to be ignorant, you can use lateral thinking without the constraint of knowledge!
I'm going to watch the open golf now, my brain hurts. Thank you all very much
|
|
|
Post by Walt Decker on Jul 15, 2021 14:03:49 GMT -5
Basic premes:
"Only one window can have focus at any given time."
1. LB cannot detect focus when an edit control is selected because there is no event handler for an edit control. Therefore, GetFocus() will not work.
2. Each control has a unique ID number that can be retrieved using GetDlgCtrlID() or GetWindowLong() so you can use those numbers to determine which control is clicked by using EnumChildWindows() in a pseudo callback to determine which edit control has the focus after it is clicked.
3. When the edit control is found in the pseudo callback set a global variable to the ID
4. When the key pad gains the focus the edit control loses the focus
5. When a button is selected on the key pad the key pad loses the focus
So, use the global set in the pseudo callback to populate the appropriate callback
|
|
|
Post by Rod on Jul 15, 2021 14:09:19 GMT -5
step too far, you need to use the API to find what has focus, that replaces the mouse x,y You will get much better advice if you post a short working example of the display you have created so far, two text boxes is enough. So the popup keypad can be created a dozen different ways. What we are about now is deciding which textbox is in play, how and when to pop up the input keypad and how to direct input and move on when done. As I say a short example of your input handling for textboxes would help. Include your goto validation and wait routine.
|
|