Liberty BASIC Community Forum
« How to make button "immune" for second klick ? »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 5:48pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: How to make button "immune" for second klick ?  (Read 361 times)
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx How to make button "immune" for second klick ?
« Thread started on: May 30th, 2017, 04:22am »

Hi ,

how to avoid that an error occur WHEN the user

is klicking on the button in Main window again ?

Or in other words , can the button recognise

that the label [new] is already made and therefore

avoid a second action ?


Code:

nomainwin

button #first.1  "new window" , [new] , UL, 20, 20, 100, 100

Open "GUI-Window" For Window As #first
Print #first, "TrapClose Quit "

Wait

end

[new]
     Open "GUI-Window" For Window As #second
     Print #second, "TrapClose Quit "

     '#first.1 "!Hide"   This command is an option to hide the button in main window but
     '                   how to show it again after the second window is closed ?

Wait

Sub Quit handle$
    Close #handle$
End Sub

 
:P



WBR Zabo
« Last Edit: May 30th, 2017, 04:32am by Zabo » User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: How to make button "immune" for second klick ?
« Reply #1 on: May 30th, 2017, 06:22am »

Managing Multiple Windows

Adding flag to your code:
Code:
nomainwin
global flagSecondOpen

button #first.1  "new window" , [new] , UL, 20, 20, 100, 100

Open "GUI-Window" For Window As #first
Print #first, "TrapClose Quit "

Wait

end

[new]
    if flagSecondOpen then wait 'if second is open, no more openings

     Open "GUI-Window" For Window As #second
     Print #second, "TrapClose Quit "
     flagSecondOpen=1

     '#first.1 "!Hide"   This command is an option to hide the button in main window but
     '                   how to show it again after the second window is closed ?

Wait

Sub Quit handle$ 
    Close #handle$ 
    if  handle$ = "#second"  then flagSecondOpen = 0    'if second is closed, allow to open it again
End Sub
 
« Last Edit: May 30th, 2017, 06:44am by tsh73 » User IP Logged

damned Dog in the Manger
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: How to make button "immune" for second klick ?
« Reply #2 on: May 30th, 2017, 11:03am »

;) Thank you for the code.

What do you think about this solution ?

Code:

nomainwin

button #first.1  "new window" , [new] , UL, 20, 20, 100, 100

Open "GUI-Window" For Window As #first
Print #first, "TrapClose [quit1]"
Wait
[quit1]
        close #first
        end




[new]
     statictext #second.0 , "put something in here and only if you are ready with that , the path goes back to main window. got it ?" , 10, 10, 200, 50
     textbox #second.1, 20, 80, 100, 100
     Open "GUI-Window" For dialog_modal As #second
     Print #second, "TrapClose [quit2] "
Wait
 [quit2]
           close #second
           wait


 



Seems easy.
User IP Logged

kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Re: How to make button "immune" for second klick ?
« Reply #3 on: May 30th, 2017, 3:19pm »

one thing you could do is disable the button as soon it has been clicked.

Code:
print #handle.ext, "!disable"
This causes the control to be inactive and grayed-out. 
User IP Logged

KEVIN
kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Re: How to make button "immune" for second klick ?
« Reply #4 on: May 30th, 2017, 3:20pm »

one thing you could do is disable the button as soon it has been clicked.

Code:
print #handle.ext, "!disable"
This causes the control to be inactive and grayed-out. 
User IP Logged

KEVIN
tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1732
xx Re: How to make button "immune" for second klick ?
« Reply #5 on: May 31st, 2017, 02:23am »

Quote:
What do you think about this solution ?

Does it work for you?
If so, fine. Case closed
B)
User IP Logged

damned Dog in the Manger
kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Re: How to make button "immune" for second klick ?
« Reply #6 on: May 31st, 2017, 03:18am »

Code:
nomainwin
global flagSecondOpen

button #first.1  "new window" , [new] , UL, 20, 20, 100, 100

Open "GUI-Window" For Window As #first
Print #first, "TrapClose Quit "

Wait

end

[new]
    if flagSecondOpen then wait 'if second is open, no more openings

     Open "GUI-Window" For Window As #second
     Print #second, "TrapClose Quit "
     flagSecondOpen=1
     '==============================
 print #first.1 , "!disable"'  MAKE THE BUTTON INACTIVE
     '==============================

     '#first.1 "!Hide"   This command is an option to hide the button in main window but
     '                   how to show it again after the second window is closed ?

Wait

Sub Quit handle$ 
    Close #handle$ 
    if  handle$ = "#second"  then flagSecondOpen = 0    'if second is closed, allow to open it again
End Sub
 

T enable the button
Code:
print #first.1 , "!enable" 



« Last Edit: May 31st, 2017, 04:32am by kevin » User IP Logged

KEVIN
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: How to make button "immune" for second klick ?
« Reply #7 on: May 31st, 2017, 1:06pm »

Thanks kevin for that code examples.

I will try the options here.

WBR
Zabo



One moment kevin.

We have the issue here , now let's get to the point !

You say in your code example that the commands

enable and disable are good ones for the choice of

exactly chosen widgets in the MAIN WINDOW.

to pick out specified. right.

that's the professional method for that.

In my actual database project it is good to block the whole Main Window that the user cannot klick to
anything.
The Main Window contains many widgets such like
main Windows do.

Furthermore my question :

Is the code that i have experiment with here
a stable and recognised solution for that.

This one :

Open "GUI-Window" For dialog_modal As #second

Is dialog_modal a stable solution to start second Main windows from main and get back ??

second MAIN WIN not small ones.

WBR
Zabo


One thing is shure : the code works in the first testing

See here :

Code:

nomainwin

button #first.1  "new window" , [new1] , UL, 20, 20, 100, 100
button #first.2  "new window" , [new2] , UL, 200, 20, 100, 100

Open "GUI-Window" For Window As #first
Print #first, "TrapClose [quit1]"
Wait
[quit1]
        close #first
        end




[new1]
     statictext #second.0 , " WINDOW 1 --put something in here and only if you are ready with that , the path goes back to main window. got it ?" , 10, 10, 200, 50
     TextboxColor$ = "green"
     textbox #second.1, 20, 80, 100, 100
     Open "GUI-Window" For dialog_modal As #second
     Print #second, "TrapClose [quit2] "

Wait
 [quit2]
           close #second
           wait



[new2]
     statictext #third.0 , "WINDOW 2--put something in here and only if you are ready with that , the path goes back to main window. got it ?" , 10, 10, 200, 50
     TextboxColor$ = "red"
     textbox #third.1, 20, 80, 100, 100
     Open "GUI-Window" For dialog_modal As #third
     textboxColor$= "green"
     Print #third, "TrapClose [quit3] "
Wait
 [quit3]
           close #third
           wait




 




« Last Edit: May 31st, 2017, 4:14pm by Zabo » User IP Logged

kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Re: How to make button "immune" for second klick ?
« Reply #8 on: Jun 1st, 2017, 03:06am »

Windows of type "dialog" are similar to windows of type "window" in that they can contain all of the other controls except menus. Menus cannot be placed on a dialog window. Dialog windows allow the user to hit the TAB key to move focus from one control to the next. A dialog can have a default button that is activated when the user hits the ENTER key. For this reason, texteditors do not work well in dialog windows, because hitting ENTER is trapped by the window and the user cannot add a carriage return to text in a texteditor. Dialog windows are best suited for getting information from a user, although it is possible to have applications that are dialog-based. Dialog windows may display as "modal." This means that they receive the input focus for the program until they are closed. Other program windows cannot be accessed by a user while a modal dialog is displayed.

If you also look in the help files at window types you might come across something you might be looking for otherwise
Code:
Liberty BASIC Programmer's Encyclopedia 
Code:
http://redirect.viglink.com/?format=go&jsonp=vglnk_149630429032221&drKey=1134&libId=j3e4vyuv010004n1000DA15uae3dqv0rbu&loc=http%3A%2F%2Flibertybasic.conforums.com%2Findex.cgi&v=1&out=http%3A%2F%2Flbpe.wikispaces.com%2F&title=Liberty%20BASIC%20Community%20Forum%20-%20Home&txt=Liberty%20BASIC%20Programmer's%20Encyclopedia 
« Last Edit: Jun 1st, 2017, 03:07am by kevin » User IP Logged

KEVIN
kevin
Senior Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 418
xx Re: How to make button "immune" for second klick ?
« Reply #9 on: Jun 1st, 2017, 03:11am »

hope this Helps
also if you have any other questions I would be glad to answer, I WILLL HEALP YOU WERE I CAN wink
User IP Logged

KEVIN
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2833
xx Re: How to make button "immune" for second klick ?
« Reply #10 on: Jun 1st, 2017, 09:45am »

Here is the simplest possible example of using the modal dialog technique.

Code:
  button #win.new, "New Item", [open], UL, 10, 10, 70, 25
  open "Parent" for window as #win
  wait

[open]
  open "Child (modal)" for dialog_modal as #child
  #child "trapclose [closeChild]"
  wait

[closeChild]
  close #child
  wait 


User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: How to make button "immune" for second klick ?
« Reply #11 on: Jun 1st, 2017, 2:31pm »

[youtube]

https://www.youtube.com/watch?v=VErdKGvakrs

[/youtube]
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls