It is currently Tue Jun 27, 2017 10:32 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Touch 2 times to exit !! the challenge...
Unread postPosted: Wed Jun 14, 2017 4:52 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 866
Location: France
Hello folks,

maybe I drown in a glass of water, but I can't get what I want (which seemed to me simple at first) :

Code:
REM  @Cassiope34 0617

gr.open 255,0,0,0,0,0    % black & landscape
gr.screen w,h
scx =1280 : scy =800
sx =w/scx : sy =h/scy
gr.scale sx, sy

gr.text.size 42 : gr.text.align 2
gr.color 255,0,255,0,1
gr.text.draw nul, scx/2, 100, "The challenge :"
gr.text.draw nul, scx/2, 200, "at any moment if you touch 'Back Key' 2 times in less than"
gr.text.draw nul, scx/2, 300, "1.5 seconds (for example), then you exit WITHOUT ANY POPUP"
gr.text.draw nul, scx/2, 400, "else you have the popup that say you that you must touch "
gr.text.draw nul, scx/2, 500, "BackKey 2 times to exit..."

DO
  new =0
  Do

    do
      gr.touch touched, x, y
      if !background() then gr.render
    until touched | new | quit
    if new | quit then D_U.break

    do
      gr.touch touched, tx, ty
    until !touched


  Until new
UNTIL quit
END "Bye...!"

OnBackKey:
quit =(clock()-t1<1500)
if !t1 : t1 =clock() : popup " Touch 2 times to exit "
elseif !quit : t1 =0
endif
back.resume


The most important for me being obviously to NOT see the POPUP when BackKey is pressed 2 time to exit...! :) :) :oops:

Any idea are well done ;) :)

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Last edited by Cassiope34 on Thu Jun 22, 2017 12:45 am, edited 3 times in total.

Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Thu Jun 15, 2017 1:07 am 
Offline

Joined: Wed Apr 15, 2015 3:57 am
Posts: 450
Code:
OnBackKey:
if t1 then quit =(clock()-t1<1500)
if !t1 then t1=clock()
if t1 & (clock()-t1>1500)
popup " Touch 2 times to exit "
t1=0
endif
back.resume


Hope this works...


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Thu Jun 15, 2017 2:37 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 866
Location: France
Thanks for that quick answer cterp :)

Unfortunately I wrote this : ( which is the same as what you propose and I liked ;) )
Code:
OnBackKey:
if t1 then quit =(clock()-t1<1500) else t1=clock()
if t1 & (clock()-t1>1500) then popup " Touch 2 times to exit " : t1=0
back.resume

But it does not work as hoped :oops: :oops:

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Thu Jun 15, 2017 6:55 am 
Offline

Joined: Wed Apr 15, 2015 3:57 am
Posts: 450
How about this:

Code:
OnBackKey:
if t1 then quit =(clock()-t1<1500) else t1=clock()
if t1 & (clock()-t1>=1500) then popup " Touch 2 times to exit " : t1=clock()
back.resume


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Mon Jun 19, 2017 6:43 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 866
Location: France
Same unsuccess cterp ( sorry for the answer delay :( )

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Mon Jun 19, 2017 11:47 pm 
Offline
User avatar

Joined: Sat Dec 08, 2012 2:14 am
Posts: 1147
Location: From Blighty
This is very crude Gilles, I think this works? It seems to...ish...

Code:
elapsed = CLOCK()
DO
PAUSE 1

IF CLOCK() - elapsed  > 3000
   elapsed = CLOCK()
   PRINT "Event trap passed...", isRunning
   isRunning = 0
   incrementOfBackKey = 0
ENDIF

IF incrementOfBackKey
   isRunning = isRunning + 1
ENDIF

IF isRunning = 1 THEN POPUP "Touch 2 times to exit"

IF incrementOfBackKey = 2 & isRunning < 1500 THEN END "END within approx 1500 seconds..."

UNTIL 0

ONBACKKEY:
incrementOfBackKey = incrementOfBackKey + 1
PRINT "Back key pressed"
BACK.RESUME


I found a resource for the technical bods, if at all relevant:-

https://stackoverflow.com/questions/843 ... n-activity

I'll try and post my own inane theory later if I get time! As I like conundrums like this...

Mog


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Tue Jun 20, 2017 12:29 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 866
Location: France
Very interesting angle of attack MOG ! ;)

OnBackKey interrupt do only one thing : increase a variable. All is donne into the principal loop... I'll try this theory... but doesn't seem so easy to integrate into my sample code of my first post !!

My goal is still as usual to get the desired result with least amount of writing because I'm lazy;)

I can not wait to see the fruit of your "own inane theory" MOG :) :)

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Tue Jun 20, 2017 11:14 pm 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1337
Hi Gilles

Not just what you want, but may be worth a look ;)
Code:
Rem Double tap back key to end

gr.open 255, 117, 117, 255
gr.color 255, 255, 255, 255
gr.text.size 30

gr.screen screenWidth, screenHeight
gr.text.draw t, 50, screenHeight / 2, "Double Tap Back Key to End"
gr.render

do
   pause 1
until 0   


!------------------------------------------------
! BackKey interrupt. Double tap back key to end
!------------------------------------------------
onBackKey:
    gosub backKeyHit
back.resume


!------------------------------------------------
! Double tap Back Key to end
!------------------------------------------------
BackKeyHit:
    inTime = 3 % Three seconds
    if backKeyHit = 3 then backKeyHit = 0
   
    if backKeyHit = 1 then
        outTime = time() - backTick
        outTime /= 1000
        if outTime > inTime then backKeyHit = 0
    endif
   
    backKeyHit ++
   
    if backKeyHit = 1 then
        backTick = time()
        popup "Press again to Exit"
    endif
   
    if backKeyHit = 2 then
        backTock = time() - backTick
        backTock /= 1000
        if backTock <= inTime then end
    endif
   
return


Regards Roy


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Wed Jun 21, 2017 2:31 am 
Offline

Joined: Sat Mar 02, 2013 11:04 am
Posts: 866
Location: France
Hello Roy, how are you ? :)

I begin to believe that this is an impossible challenge... :oops: :evil: :roll:

Your solution give me the same result as that of Chris or Mog or mine... unsuccess :evil:

The only way I see could be that JMarc return us the double tab on BackKey !!! ;) ( ex: with a small function DblTapBKey() that returns 0 or 1 )

A lot of officials programs use this way to exit.

Meanwhile I continue to seek a solution :)

Cheers

Gilles

_________________
"It is better to mobilize intelligence for stupid things, rather than mobilizing stupidity for intelligent things."
Galaxy TAB S 8.4, 2560x1600, Marshmallow 6.0.1
Galaxy Note II, 1280x720, JB4.1.2
Galaxy A3, 1280x720, Android 6.0.1


Report this post
Top
 Profile  
 
 Post subject: Re: Touch 2 times to exit !! the challenge...
Unread postPosted: Wed Jun 21, 2017 4:23 am 
Offline
User avatar

Joined: Wed Jul 10, 2013 8:11 am
Posts: 359
Hi Gilles,

try this
Code:
REM  @Cassiope34 0617
backKeyCounter = 0                       %   ********** NEW *********
gr.open 255,0,0,0,0,0    % black & landscape
gr.screen w,h
scx =1280 : scy =800
sx =w/scx : sy =h/scy
gr.scale sx, sy

gr.text.size 42 : gr.text.align 2
gr.color 255,0,255,0,1
gr.text.draw nul, scx/2, 100, "The challenge :"
gr.text.draw nul, scx/2, 200, "at any moment if you touch 'Back Key' 2 times in less than"
gr.text.draw nul, scx/2, 300, "1.5 seconds (for example), then you exit WITHOUT ANY POPUP"
gr.text.draw nul, scx/2, 400, "else you have the popup that say you that you must touch "
gr.text.draw nul, scx/2, 500, "BackKey 2 times to exit..."

DO
  new =0
  Do

    do
      gr.touch touched, x, y
      if !background() then gr.render
    until touched | new | quit
    if new | quit then D_U.break

    do
      gr.touch touched, tx, ty
    until !touched

  Until new
UNTIL quit
END "Bye...!"

OnTimer:                          % vv ********** NEW *********
   IF backKeyCounter = 1
      popup " Touch 2 times to exit! "
      TIMER.CLEAR
      backKeyCounter = 0
   ENDIF
TIMER.RESUME
OnBackKey:
   backKeyCounter++
   IF backKeyCounter = 1
      TIMER.CLEAR
      TIMER.SET 1500
   ENDIF
   IF backKeyCounter = 2
      END "Bye...!"
   ENDIF
back.resume                                   % ^^ NEW ********** NEW *********


Happy coding
Gregor


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred