Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:49 01 May 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 : Question about GUI controls

     Page 1 of 2    
Author Message
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 03:37am 25 Sep 2015
Copy link to clipboard 
Print this post

For the text box, spin box, and number box controls, how hard would be to have ghost hints in them if there is no pre-loaded data?
I mean something like if we have a text box and it needs entering a name, when it is blank to have a default hint text with some reduced colour in it saying for example "name"

http://rittle.org

--------------
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 02:15pm 25 Sep 2015
Copy link to clipboard 
Print this post

This is getting fancy!

Actually it would be easy to do, the only problem is how to implement this feature without messing up the syntax of the relevant commands. Thanks for the idea, I will investigate.

EDIT: This could be done using CTRLVAL as a command after the text or number box has been created. For example; CTRLVAL(#10) = "Enter Name"

GeoffEdited by Geoffg 2015-09-27
Geoff Graham - http://geoffg.net
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 10:13pm 25 Sep 2015
Copy link to clipboard 
Print this post

  Geoffg said  
EDIT: This could be done using CTRLVAL as a command after the text or number box has been created. For example; CTRLVAL(#10) = "Enter Name"


That actually crossed my mind too, but the problem with this solution is that once loaded with CTRLVAL, the hint becomes inseparable from actual data, both for the program and the user.
http://rittle.org

--------------
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 03:53am 26 Sep 2015
Copy link to clipboard 
Print this post

I am having second thoughts about this. Why do you need "ghost text", normally the text box (or whatever) would have a caption saying something like "File Name:". That should give the user the prompt.
Geoff Graham - http://geoffg.net
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 04:13am 26 Sep 2015
Copy link to clipboard 
Print this post

  Geoffg said   I am having second thoughts about this. Why do you need "ghost text", normally the text box (or whatever) would have a caption saying something like "File Name:". That should give the user the prompt.


Hi Geoff. Yes, you are correct with this assumption, but only if the screen is large enough to fit captions and boxes at the same time. With displays with lower resolution the problem becomes visible once you have a few data entry controls on the screen. That's why I thought by having ghost hints would be much more effective way to save space from the captions. This is actually used everywhere in the smartphones as well, so the approach is not new.

http://rittle.org

--------------
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 04:45am 26 Sep 2015
Copy link to clipboard 
Print this post

  kiiid said  
  Geoffg said  
EDIT: This could be done using CTRLVAL as a command after the text or number box has been created. For example; CTRLVAL(#10) = "Enter Name"


That actually crossed my mind too, but the problem with this solution is that once loaded with CTRLVAL, the hint becomes inseparable from actual data, both for the program and the user.


Just have your program check that the value for CTRLVAL(#10) <> "Enter Name", then you know that the user has entered a value.
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 06:47am 26 Sep 2015
Copy link to clipboard 
Print this post

  Greg Fordyce said  
Just have your program check that the value for CTRLVAL(#10) <> "Enter Name", then you know that the user has entered a value.


That's kind of obvious, but again - the data may not be distinguished from the hint, since the hint appears as real data. What if I entered "Enter Name" and that was my real data? I agree that there are workarounds, but none of them is perfect. I am trying to introduce the mite into the world of serious applications, hence my initial question.Edited by kiiid 2015-09-27
http://rittle.org

--------------
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 06:59am 26 Sep 2015
Copy link to clipboard 
Print this post

I do lots of GUI stuff on the web and on smartphones and in both cases the hint is very useful.
The visual feedback is that once a single character is entered (on the keydown, or touch) the hint disappears.
I think lots of people are used to it and having the least amount of new GUI stuff is very user friendly.
Even large screen use it often as the GUI design can be much more efficient.
On small screens where screen real estate is already at a minimum having the opportunity to save every pixel possible is welcome.



Edited by MicroBlocks 2015-09-27
Microblocks. Build with logic.
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 09:22am 26 Sep 2015
Copy link to clipboard 
Print this post

  MicroBlocks said   I do lots of GUI stuff on the web and on smartphones and in both cases the hint is very useful.
The visual feedback is that once a single character is entered (on the keydown, or touch) the hint disappears.


This already happens with a TEXTBOX and NUMBERBOX. As soon as you touch the control the value is cleared when the keyboard pops up.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:35pm 26 Sep 2015
Copy link to clipboard 
Print this post

Interesting, I will add this one to the ever growing list. It could be done transparently for the programmer. Ie, the control would return an empty string even if he has set the ghost text

At this time I am still working on the 100 pin version of the MM+ and chasing down bugs - so it will be a little while before I get to new features like this.


Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2290
Posted: 06:18pm 26 Sep 2015
Copy link to clipboard 
Print this post

how about adding a non-printing, non-enterable character to the hint text, such as chr$(255)? or chr$(0)? as long as this character is not displayed and the user can not enter it into the box as part of a response this would serve as a means of distinguishing between hint and any user-entered data.

cheers,
rob :-)Edited by robert.rozee 2015-09-28
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 09:30pm 26 Sep 2015
Copy link to clipboard 
Print this post

This is a very good idea actually. Thanks for that.
Of course from visual point of view the problem will still exist because data and hints will look exactly the same, but at least it is working solution as a starting point.
http://rittle.org

--------------
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5907
Posted: 09:48pm 26 Sep 2015
Copy link to clipboard 
Print this post

Whatever is in the textbox is cleared as soon as the keyboard appears so any prompt is automatically removed.
But...
Is there any way to 'cancel' a text or number input once it has started?
As far as I can see, once started you have to press 'enter' to complete the entry.

With textboxes, a blank string can be generated but with number boxes, 'zero' is not a safe way to indicate a nul entry.

Jim
VK7JH
MMedit   MMBasic Help
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:26am 27 Sep 2015
Copy link to clipboard 
Print this post

No, there is no "cancel" button... not enough spare keys on the main keyboard/keypad but it could be done on the alternate keys. Is this important? It seems to me that you could just re-enter whatever was there before.
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5907
Posted: 05:47pm 27 Sep 2015
Copy link to clipboard 
Print this post

  Geoffg said   No, there is no "cancel" button... not enough spare keys on the main keyboard/keypad but it could be done on the alternate keys. Is this important? It seems to me that you could just re-enter whatever was there before.


Most end users would expect a cancel or 'back' button such as on android (and I assume ipad) devices.
It is easy to hit the wrong spot on the touch screen and have no idea what the original data was.

A separate button that can be used as a cancel or back button would be OK provide we had a way to close the keyboard from code.

Jim



VK7JH
MMedit   MMBasic Help
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 02:36am 28 Sep 2015
Copy link to clipboard 
Print this post

Here's another way to have a ghost hint in a TEXTBOX without the hint being considered as part of the program's data. The value from the text box is stored in name$ which is initialized to "". Then CTRLVAL(1) = "Enter Name" sets the ghost hint into the TEXTBOX without affecting the program data. After a value is entered it is then stored in name$ to be used as data in the program. If a user doesn't enter a value the ghost hint reappears. The background colour is also changed from gray to white to distinguish between actual data or ghost hint in the TEXTBOX.

CLS
Font 5
name$ = "" 'Name initialized to ""
GUI textbox 1, 0, 0, 250, 50, RGB(blue), RGB(gray)
CtrlVal(1) = "Enter Name" 'Ghost hint
GUI interrupt pendown, penup
Text 0, 60, name$ ' Show value of name$
Do : Loop

Sub pendown
End Sub

Sub penup
Select Case Touch(LASTREF)
Case 1
If CtrlVal(1) = "" Then
CtrlVal(1) = "Enter Name" 'invalid entry, set ghost hint
GUI bcolour RGB(gray), 1
name$ = ""
Text 0, 60, " "
Text 0, 60, name$
Else
name$ = CtrlVal(1) 'Valid textbox entry now set to name$
GUI bcolour RGB(white), 1 'change background colour to show value entered correctly
Text 0, 60, name$ 'show value of name
EndIf
End Select
End Sub


When I run this on a Explore 64 with ssd1963 7" screen using 4.7B31 there is a curious bug. If you touch anywhere on the screen outside of the TEXTBOX after touching the TEXTBOX and pressing <Ent> the ghost text "Enter Name" gets stored in name$. I am not sure if this is a problem with my code or a bug in MMBASIC.

EDIT - Can someone try this with beta 32 and see if the bug happens for them?

EDIT 2 - The bug happens because of this line of code.
Select Case Touch(LASTREF)
If I use Touch(REF) the select case doesn't work. But when I touch anywhere else on the screen the last valid control I touched was TEXTBOX(1) even though my next touch wasn't a valid control. Should Touch(LASTREF) remember the last valid control touched even though there are later touches that weren't on a valid control?Edited by Greg Fordyce 2015-09-29
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 03:59am 28 Sep 2015
Copy link to clipboard 
Print this post

Interesting...
I will give it a run as soon as I have a system around.
http://rittle.org

--------------
 
Greg Fordyce
Senior Member

Joined: 16/09/2011
Location: United Kingdom
Posts: 153
Posted: 08:26am 28 Sep 2015
Copy link to clipboard 
Print this post

I think the problem with my bug in the sample code above has to do with "Select Case Touch(LASTREF)". Touch(REF) won't work because I am calling the subroutine after releasing the control, so there is no control touched for the case statement to reference. On the other hand the Touch(LASTREF) returns the last control touched even if there where other touches to the screen outside of any control. I can see why this is necessary because when you call a virtual keyboard/keypad you have lots of touches after touching the control and still need to what control was touched.

Is there a way to clear/reset Touch(LASTREF) to zero after using it? Maybe a POKE command as a short term solution?

EDIT - Can a Touch(LASTREF)= command be added to MMBASIC? Valid range would be 0-100. Edited by Greg Fordyce 2015-09-29
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 03:35am 07 Oct 2015
Copy link to clipboard 
Print this post

Returning back to the 'Cancel' button. How about the second screen with ALT? I see there is a lot of blank ones there.
http://rittle.org

--------------
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:35pm 07 Oct 2015
Copy link to clipboard 
Print this post

] have added it to the "to be investigated" list. The main problem is what caption to put on the Key. You can only have three letters and "Can" seems to cryptic.
Geoff Graham - http://geoffg.net
 
     Page 1 of 2    
Print this page
© JAQ Software 2024