Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 02:00 21 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite - Help with GUI TEXTBOX ACTIVATE

     Page 1 of 2    
Author Message
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 04:50am 14 Jul 2022
Copy link to clipboard 
Print this post

Hi All,
Sorry to be a 'serial help-seeker' but I have really tried to resolve this one.

I'm wanting to define a TEXTBOX at the beginning of a program and then, within a subroutine (after CLS) SHOW it and then ACTIVATE it.
All I get is the RBOX holder for the text which is populated as I tap unseen characters on the screen - <ENT> still works (when I can eventually locate it).

It works OK within the body of the program.

Do any of you have sample code that does this?

Here is my test program - it is a fragment of a larger program hence the silly names.
(Edit: I am on MM version 5.07.04, using an ILI9488 480x320 display in Portrait mode)

Many thanks,

Andrew
PS: the '#' in 'GUI TEXBOX ACTIVATE #ref' gives a syntax error, 'GUI TEXBOX ACTIVATE ref' does not.


'TextboxForTBS.BAS
 
 const c.LGray   = RGB(190,190,190)
 Const c.Get_PW  = RGB(Cyan)
 Const TB.Password = 1
 Const TB.Get_PW   = 2  '
 
 font 3
 GUI TEXTBOX TB.Password,1,170,mm.hres-2,40,RGB(green),c.LGray
 GUI DISPLAYBOX TB.Get_PW, 1,1,mm.hres/2,40,c.Get_PW, rgb(Black)
 CTRLVAL(TB.Get_PW) = "Get PW"
 
 GUI INTERRUPT PenDown   ', PenUp
 CLS
 GUI Show TB.Get_PW
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
 do
     
 Loop While ASC(Inkey$) <> 27
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
End
 
Sub PenDown
 select case touch(ref)
   case TB.Password
     print "Password Entered"
   Case TB.Get_PW
     print "'Get_PW' Tapped"
     Get_Password
 end Select
End Sub 'PenDown
 
SUB PenUp
 SELECT CASE TOUCH(LASTREF)
   CASE TB.PassWord
     Print "Here at PenUp"
 END SELECT
END SUB
 
Sub Get_Password
 Cls
 Gui Show TB.Password
 CtrlVal(TB.Password) = ""
 GUI TEXTBOX ACTIVATE 1  '#1 gives error  'TB.Password
 
do:loop while CtrlVal(TB.Password) = ""
 gui hide TB.Password 'Without this it is still active.
 Text MM.Hres/2,mm.vres/2, CTRLVAL(TB.Password), CM, 3,, RGB(Green)
 pause 3000
end Sub


Edited 2022-07-14 16:57 by Andrew_G
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2868
Posted: 10:07am 16 Jul 2022
Copy link to clipboard 
Print this post

Hi Andrew,

I am not in a position to play with your code at the moment but is it possible that it has to do with LOCAL and GLOBAL variable?

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 11:29pm 16 Jul 2022
Copy link to clipboard 
Print this post

Hi Mick,
Thanks for that - I've tried putting it in SUBs and FUNCTIONs, with Global and LOCAL parameters etc but unfortunately none of them work. (they draw the RBOX but neither tapping the box nor 'ACTIVATE ref' activates the keyboard. (Individual characters on the keyboard do become active when tapped - but it is hard to type when you can only see characters after you have typed them . . .).

My work around, which works, is to have the code in the main loop and use the Pendown interrupt to set a flag which ACTIVATES the keyboard and captures the Password etc.
But this ties up the running program. Not a big deal if it is only in 'setup' mode.

Thanks again,

Andrew
Edited 2022-07-17 09:30 by Andrew_G
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1773
Posted: 12:13am 17 Jul 2022
Copy link to clipboard 
Print this post

If there is an SD card attached another work around for the invisible keyboard might be to keep an image of the keyboard on the card. Use Ctrl-C when the KB is showing then type SAVE IMAGE "Keyboard.BMP". Repeat that when the KB is not showing - SAVE IMAGE "NoKeyboard.BMP". Your SUB can then LOAD IMAGE "Keyboard.BMP" when needed and restore the screen afterward.

Edit
After saving the images use a image editor to crop just the keyboard part of the screen then the SUB does LOAD IMAGE "Keyboard.BMP",x,y to leave the rest unchanged. Likewise with NoKeyboard.BMP.
If using Paint as the editor x and y can be found by moving the mouse to the top left corner of the keyboard - before cropping - the coordinates of the mouse show on the bottom left of the window.
Edited 2022-07-17 10:32 by phil99
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 12:53am 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks Phil,
I agree that might work but I don't currently have an SD card connected.

BUT I was rather hoping that one of the 200 people reading this post might have been able to point out the error of my ways, OR,
does ACTIVATE not work as described in the manual??

Has anyone out there in TBS Land used GUI TEXTBOX ACTIVATE?

Cheers,

Andrew
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1796
Posted: 02:36am 17 Jul 2022
Copy link to clipboard 
Print this post

Have you set OPTION GUI CONTROLS
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 08:53am 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks Paul.
I hadn't first time around but MMBasic prompts you to do so. I've now got more than enough memory set aside for GUI controls.

Cheers,

Andrew
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 09:21am 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks Paul.
I hadn't first time around but MMBasic prompts you to do so. I've now got more than enough memory set aside for GUI controls.

Cheers,

Andrew
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 843
Posted: 09:59am 17 Jul 2022
Copy link to clipboard 
Print this post

Hi Andrew,
I think much of the issue is because you are calling get_Password from within the pendown interrupt code. Try setting a flag and then act on that flag in the main loop.



  Quote   GUI Show TB.Get_PW
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
 
DO
   
IF GetPassword=1 THEN
    GetPassword=
0
    Get_Password
   
ENDIF
 
LOOP WHILE ASC(INKEY$) <> 27
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
END
 
SUB PenDown
 
SELECT CASE TOUCH(REF)
   
CASE TB.Password
     
PRINT "Password Entered"
   
CASE TB.Get_PW
     
PRINT "'Get_PW' Tapped"
     getpassword=
1
     
'Get_Password
 
END SELECT
END SUB 'PenDown

Latest F4 Latest H7
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 10:30am 17 Jul 2022
Copy link to clipboard 
Print this post

Hi Disco,
Thank you to you too. Your approach does work but not by ACTIVATEing (sic) the keyboard.
That approach is the essence of the workaround I refer to above - but it still does not ACTIVATE the keyboard (as described on Page 58 of the manual).
'GUI TEXTBOX ACTIVATE ref' appears (to me) to be not behaving as described.

Thanks again,

Andrew
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5707
Posted: 11:50am 17 Jul 2022
Copy link to clipboard 
Print this post

I'm not sure it works the way you think, Andrew. If you create the textbox and call it *in the same subroutine* or do both in the body of the program I think it works as in the manual, but I don't think you can split them. I haven't got anything set up to test it on at the moment, unfortunately.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 11:59am 17 Jul 2022
Copy link to clipboard 
Print this post

Can someone test Andrew's original code on a MM+? It is perfectly possible there is a bug in the GUI implementation on the Pico but I need more info to confirm it one way or the other
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 12:03pm 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks Mick.
I think that is one of the variations I tried but I'll give it a go in the morning. UTC + 10 here.
The other controls seem to be able to be split. I'll have to put an ON ERROR SKIP before the definition if used in a SUB.

Cheers,

Andrew
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 12:11pm 17 Jul 2022
Copy link to clipboard 
Print this post

Thanks Peter for chiming in.
It will certainly help my sanity if someone can replicate it.
The '#' before the ref number certainly upsets it.

If I don't respond for a few hours it is not lack of interest - but lack of sleep (chasing this down).

Cheers to you all,

Andrew
Edited 2022-07-17 22:41 by Andrew_G
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 01:57am 18 Jul 2022
Copy link to clipboard 
Print this post

@matherp and @Andrew_G,

On the Pico, it appears that GUI TEXTBOX ACTIVATE and GUI INTERRUPT are mutually exclusive with respect to displaying the virtual keyboard.

In the program below, if you comment out GUI INTERRUPT, the virtual keyboard displays and accepts keypress' correctly. If you enable the GUI INTERRUPT line, the virtual keyboard does not display but it is actually in place and pressing where the keys would normally be produces the correct output.


CLS
Font 3
GUI TEXTBOX 1,0,200,MM.HRes-2,40,RGB(green),c.LGray
CtrlVal(1) = "##Enter password"

' GUI INTERRUPT PenDown

Do
  GUI TEXTBOX ACTIVATE 1
  Pause 3000
  GUI TEXTBOX CANCEL
  Pause 3000
Loop
End

Sub PenDown
Select Case Touch(ref)
  Case 1
    Print "Password Entered"
End Select
End Sub


The hash '#' is not accepted for GUI ACTIVATE or the PAGE commands.

On an E100 running 5.05.03, GUI TEXTBOX ACTIVATE throws a syntax error for both 1 and #1 as the reference using exactly the same code above. Because of this, I am unable to confirm the interaction with GUI INTERRUPT. Using GUI INTERRUPT enabled (not commented out) but with the GUI TEXTBOX ACTIVATE commented out, all works as expected.

One thing I noted on both Pico and MM+ is that if there is no available room for the keyboard to display without overwriting other GUI elements, it will not display. It is still there on the screen (and can be used if you 'guess' the right spots for letters and Enter) but is invisible.

Doug.

Edit: On the Pico at least, it appears a little more complex - with both ACTIVATE and INTERRUPT in play (not commented out), following the GUI TEXTBOX ACTIVATE command, if the TEXTBOX is touched, no virtual keyboard appears but it is still there in the background and touching the right spot on the display will momentarily display that key only as well as correctly grabbing the key. No Interrupt is generated while ACTIVATE is enabled.
Once the GUI TEXTBOX CANCEL command is entered, GUI INTERRUPT is now working and touches generate interrupts, virtual keyboard appears and key presses are accepted.
So the moral of the story? Don't use both GUI TEXTBOX ACTIVATE and GUI INTERRUPT together without understanding the interaction between them.

I think I have this right but still can not get GUI TEXTBOX ACTIVE to work on MM+
  D.
Edited 2022-07-18 12:29 by panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 02:40am 18 Jul 2022
Copy link to clipboard 
Print this post

Doug,
Thank you so very much.
I'm not going mad after all.

Peter, I trust that Doug's fine efforts give you some clues?
I am happy to help test fixes etc.

Kind regards,

Andrew
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 03:44am 18 Jul 2022
Copy link to clipboard 
Print this post

Interestingly (for me anyway   ), looking through the source for both versions (Pico and MM+), I can not find anywhere that ACTIVATE is tested for or acted on? I can see where CANCEL is used in gui.c. Has ACTIVATE actually been implemented? Purely uninformed speculation on my part.

Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 06:36am 18 Jul 2022
Copy link to clipboard 
Print this post

ACTIVATE looks to be there in GUI.c but the code for '#' is:

if(*pp == '#') p++;


and looks like it should be:

if(*pp == '#') pp++;


John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8570
Posted: 07:09am 18 Jul 2022
Copy link to clipboard 
Print this post

I've confirmed the issue on the MM+ - code is identical - and written to Geoff.

Well spotted John on the pp++ that will fix the # issue but not the main one
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 07:21am 18 Jul 2022
Copy link to clipboard 
Print this post

Thanks Guys,
A truly international effort!

Andrew
 
     Page 1 of 2    
Print this page
© JAQ Software 2024