Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:50 16 Jul 2025 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 : Problems with GUI HIDE ALL

Author Message
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 12:27pm 24 Feb 2016
Copy link to clipboard 
Print this post

Hi All,

GUI HIDE ALL is not performing the way I would expect!

This test code works but is slow because of the 1 sec pause. If I hold down the button it generates an error :-


Option EXPLICIT
GUI DEFAULT HIDDEN
GUI INTERRUPT guiAction

CLS
Font 1,2

' Controls that are on the screen all the time or for more than 1 screen
Const pg0Prev = 1
Const pg0Next = 2

GUI BUTTON pg0Prev, "< Prev.",10,200,130,35,RGB(BLack),RGB(Green)
GUI BUTTON pg0Next, "Next >",180,200,130,35,RGB(Black),RGB(Green)
GUI INTERRUPT guiAction ' Turn the touch interrupt on

DrawPage


' +++++++++++++++++++++++++++++ START MAIN +++++++++++++++++++++++++++++++
Do

Loop

' ++++++++++++++++++++++++++++++ SUBS BELOW ++++++++++++++++++++++++++++++

Sub guiAction
Local I,J As integer
Local TR As integer = Touch(REF)

GUI INTERRUPT 0 ' make sure we don't call again until finished processing

DrawPage

GUI INTERRUPT guiAction ' turn the touch interrupt back on
End Sub

Sub DrawPage
Local n As integer
Pause 1000
GUI HIDE ALL

' Other pages were loaded in here but removed for this test


For n = 1 To 2
GUI SHOW n
Next

End Sub




My thoughts are that the command should do as it says and hide all controls regardless of whether a control is pressed or not.

Is there a suitable workaround I have not thought of?

Rob White
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3285
Posted: 01:02pm 24 Feb 2016
Copy link to clipboard 
Print this post

Changing the state of a control while the control is being activated (touched) will generally cause a problem. This is something that I will have to look at but the solution will probably be to throw an error message if that happens.

It would be best to hide the control on the touch up interrupt as the control is not then being touched.

Geoff
Geoff Graham - http://geoffg.net
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1000
Posted: 01:15pm 24 Feb 2016
Copy link to clipboard 
Print this post

Geoff was too quick, but as I have dug this up I will add it anyway.


A similar issue is discussed in this thread. I have quoted the last entry which shows @grogster's method of not doing Deletes while actually in the control's touch code, which can manifest as many strange issues. (Later advice from Geoff and in the manual I think now suggests you should try to code so you don't need CLS when you have GUI controls i.e only use the GUI controls)

Regards
Gerry


Similiar Issue


  Grogster said   UPDATE:

I have introduced a new routine to clear the GUI which seems to be working. It is a variation of disco4now's code, but instead of tracking each control, it just waits till it detects no control being touched, and THEN it deletes the controls. This is called at the start of each NEW screen of controls via the CLEARSCR sub:


SUB CLEARSCR
Timer=0
Do:Loop Until Touch(UP)=1 'Wait until no touch control being touched.
X=Timer
If DEBUG then Print "Delete GUI in " + STR$(X) + " ms."
GUI delete all
CLS
End SUB


This seems to be working fine for the moment(no corruption), and saves me having to to keep track of individual controls.

Geoff has advised me via email, that deleting GUI controls while they are still active is a big no-no, and this was what was happening when I look at the debug delays in the new routine - it takes a few tens of ms before the touch is released(depending on how fast you are tapping buttons etc), and deleting controls as part of the new screen, when the old button is still "Down" - not a good thing.

disco4now already hinted as much in his posting on this thread, and it would seem he was indeed quite right.

Oh well - I am learning new stuff, as GUI controls are totally new territory for me!

Latest F4 Latest H7 FotS
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9593
Posted: 01:28pm 24 Feb 2016
Copy link to clipboard 
Print this post

Yes, further to this, it is vitally important not to change a control while it is still active. Geoff also mentioned to me that if you have to use CLS at all to clear the screen in a GUI, then you are doing it wrong.

This was great advice, and a nice simple rule for me to remember.

I was having similar issues with my textbox or numberbox(I forget which one), in that once I entered in the correct text, the code looped to a new screen and issued the CLS command. This cleared the screen, yes, but the box was still technically active and generated some very strange behaviour.

Using GUI DEFAULT HIDDEN and GUI HIDE ALL at the top of the code would be how I now start GUI work, and only GUI SHOW the ones you want on any one screen.

I also have to get used to using GUI CAPTION instead of TEXT, as that was also causing me screen problems.
Smoke makes things work. When the smoke gets out, it stops!
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 01:36pm 24 Feb 2016
Copy link to clipboard 
Print this post

Thanks all,

Changing to the touch up interrupt works fine!
Rob White
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025