fox
Junior Member
Posts: 66
|
Post by fox on Jun 19, 2018 10:05:21 GMT -5
Hi all. I'm wondering if it is possible to create (in a program) a "notice" that appears for 2-3 seconds and after disappears without user have to click "ok". Unfortunately i'm not able to imagine how. Any help will be precious. Bye fox
|
|
|
Post by Chris Iverson on Jun 19, 2018 10:45:31 GMT -5
Not using LB's "notice" command.
The only way to do so is to create and open your own window to show the notice, and set a timer to close it three seconds later.
|
|
fox
Junior Member
Posts: 66
|
Post by fox on Jun 19, 2018 12:11:11 GMT -5
Ok, Chris. Thanks a lot and bye. fox
|
|
|
Post by tsh73 on Jun 19, 2018 16:25:34 GMT -5
Here's code based off CustomNotice$ from Freeform-J v.261006 (only change is timeOutMS added)
nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.button1, "CustomTimedNotice", [button1Click], UL, 30, 321, 180, 25 open "untitled" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
[button1Click] 'Perform action for the button named 'button1' res$=CustomNotice$("Be fast", "You have 1 second", "Yes No", 1000) if res$<>"" then msg$="You pressed ";res$ else msg$="You were either late OR pressed ESC" end if notice msg$
res$=CustomNotice$("Try again", "Now with two seconds", "Abort Retry Ignore", 2000)
if res$<>"" then msg$="You pressed ";res$ else msg$="You were either late OR pressed ESC" end if notice msg$
wait
'Custom functions and subs: 'a bit modified CustomNotice$ from Freeform-J v.261006 ' timeOutMS added function CustomNotice$(title$, message$, buttons$, timeOutMS) 'Arguments: 'title$ - text displayed on dialog caption 'message$ - text displayed in the dialog 'buttons$ - names of 1-3 buttons 'timeOutMS - time to close. Sub return nothing like ESC pressed if word$(buttons$, 1) <> "" then yes$ = word$(buttons$, 1) count = 1 else exit function end if if word$(buttons$, 2) <> "" then no$ = word$(buttons$, 2) count = 2 end if if word$(buttons$, 3) <> "" then cancel$ = word$(buttons$, 3) count = 3 end if select case count case 1 y = 120 : n = -80 : c = -80 case 2 y = 80 : n = 160 : c = -80 case 3 y = 40 : n = 120 : c = 200 end select 'calculate window/control dimensions based on message 'assuming 55 characters per line and 14 pixel line height lineCount = int(len(message$)/55)+2 staticHeight = lineCount*14 buttonYOrg = staticHeight+30 WindowWidth = 320 WindowHeight = staticHeight+110
statictext #ync.st, message$, 10, 20, 292, staticHeight button #ync.default, yes$, [yncYes], UL, y, buttonYOrg, 70, 25 button #ync, no$, [yncNo], UL, n, buttonYOrg, 70, 25 button #ync, cancel$, [yncCancel], UL, c, buttonYOrg, 70, 25 open title$ for dialog_modal as #ync #ync.st, "!font ms_sans_serif 9" #ync, "trapclose [yncTrapclose]" timer timeOutMS, [yncTrapclose] wait [yncYes] CustomNotice$ = yes$ : goto [yncTrapclose] [yncNo] CustomNotice$ = no$ : goto [yncTrapclose] [yncCancel] CustomNotice$ = cancel$ [yncTrapclose] timer 0 close #ync end function
|
|
fox
Junior Member
Posts: 66
|
Post by fox on Jun 20, 2018 4:52:11 GMT -5
Hi tsh73. A very interesting solution. I will study your suggestion very carefully. Thanks a lot and bye. fox
|
|