code
Member in Training
Posts: 74
|
Post by code on Nov 24, 2018 9:41:42 GMT
Is it possible to move the widow(see code below) in plain Just Basic(not LB) ? Thx !
nomainwin
a=0
open "Hello world " for window_popup as #screen1 timer 50, [t] wait [t] a=a+10 UpperLeftY = UpperLeftY+a
UpperLeftX = 2000000 WindowWidth = 1 WindowHeight = 1
wait
|
|
|
Post by B+ on Nov 24, 2018 15:27:29 GMT
I can move a window in Just Basic by closing it and reopening it at the new spot. Here is an example:
global XMAX, YMAX, ULX, DIR nomainwin XMAX = 500 YMAX = 500 DIR = -1 WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (DisplayWidth - XMAX) / 2 ULX = UpperLeftX UpperLeftY = (DisplayHeight - YMAX) / 2 open "Move Window Test - click mouse to relocate window" for graphics_nsb_nf as #gr #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonUp lButtonUp" #gr "place ";190;" ";240;";|";"UpperLeftX = "+str$(ULX) wait
sub lButtonUp H$, mx, my 'must have handle and mouse x,y close #H$ WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 ULX = ULX + 100 * DIR if ULX < 0 then DIR = DIR * -1 : ULX = 10 if ULX + XMAX > DisplayWidth then DIR = DIR * -1 : ULX = DisplayWidth - XMAX UpperLeftX = ULX UpperLeftY = (DisplayHeight - YMAX) / 2 open "Move Window Test - click mouse to relocate window top, left corner" for graphics_nsb_nf as #gr #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonUp lButtonUp" #gr "place ";190;" ";240;";|";"UpperLeftX = "+str$(ULX) end sub
sub quit H$ close #H$ end end sub
|
|
code
Member in Training
Posts: 74
|
Post by code on Nov 24, 2018 18:15:01 GMT
That works... Thx !
Is it also possible with a timer ?
Code i have sofar:
nomainwin
a = 0
timer 850, [t] wait [t]
open "Hello world " for graphics as #gr a = a + 10
#gr "place ";200;" ";200;";|";"UpperLeftY = "+str$(a) close #gr
wait
|
|
|
Post by B+ on Nov 24, 2018 19:35:04 GMT
Yes, I think it is possible with TIMER but be careful. Reading over Help of TIMER I see the first thing to do in Timer branch is to turn off TIMER = 0, then do your thing (Close the window) then setup to reopen the Window in the new location, open it, and then reset the Timer with another call and then WAIT.
Comment: I imagine this is OK for very simple Windows because in more complex ones it would be hard to reset the machine state to exactly what is was before the TIMER event.
|
|
|
Post by tsh73 on Nov 24, 2018 20:45:35 GMT
|
|
|
Post by B+ on Nov 24, 2018 22:19:13 GMT
Hey cool game: Click me if you can!
'Click me if you can!.txt for JB v2 B+ 2018-11-24
global XMAX, YMAX, COUNTER, LIMIT nomainwin XMAX = 300 YMAX = 100 LIMIT = 1000 WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (DisplayWidth - XMAX) / 2 ULX = UpperLeftX UpperLeftY = (DisplayHeight - YMAX) / 2 open "Move Window Test" for graphics_nsb_nf as #gr #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonDown lButtonDown" #gr "when characterInput charIn" #gr "place ";90;" ";55;";|";"Click me if you can!" timer LIMIT, [timesup] wait
[timesup] timer 0 COUNTER = COUNTER + 1 close #gr if COUNTER > 50 then notice "Sorry, your limit is " + str$(LIMIT) end else UpperLeftX = int(rnd(0) * (DisplayWidth - XMAX)) UpperLeftY = int(rnd(0) * (DisplayHeight - YMAX)) end if open "Move "+str$(COUNTER) for graphics_nsb_nf as #gr #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonDown lButtonDown" #gr "place ";90;" ";55;";|";"Click me if you can!" timer LIMIT, [timesup] wait
sub lButtonDown H$, mx, my timer 0 LIMIT = LIMIT - 50 COUNTER = 0 notice "Got me! OK now try again." close #gr UpperLeftX = int(rnd(0) * (DisplayWidth - XMAX)) UpperLeftY = int(rnd(0) * (DisplayHeight - YMAX)) open "Move "+str$(COUNTER) for graphics_nsb_nf as #gr #gr "setfocus" #gr "trapclose quit" #gr "when leftButtonDown lButtonDown" #gr "place ";90;" ";55;";|";"Click me if you can!" timer LIMIT, [timesup] end sub
sub quit H$ close #H$ end end sub
|
|
|
Post by tsh73 on Nov 24, 2018 22:25:51 GMT
Err how one close darned thing? (had to kill Basic)
|
|
|
Post by B+ on Nov 24, 2018 22:46:00 GMT
Err how one close darned thing? (had to kill Basic) Hi tsh73, Thanks for tryout. When the COUNTER reaches 50, then it will close itself and report to you, your LIMIT = the amount of delay length you couldn't catch. But I think the delay length is just as much how fast JB can close and then reload a Window ?? I swear I clicked a window in time, many a time ;-))
|
|
code
Member in Training
Posts: 74
|
Post by code on Nov 25, 2018 7:15:06 GMT
Hi B+... thx for your time. I looked at the game ... thats great!. The idea was to make a game with square windows (window_popup)(that seems not to work).
Maybe i come up also with a game...
Regards,
code
|
|
code
Member in Training
Posts: 74
|
Post by code on Nov 25, 2018 7:48:28 GMT
I cant't get it working with a timer ,so no game... maybe over 2 months ill look at it again.
Regards,
code
|
|
code
Member in Training
Posts: 74
|
Post by code on Nov 25, 2018 17:33:31 GMT
I kept thinking of a game... and tried again... What about this code:
nomainwin UpperLeftX = 10 UpperLeftY = 10
WindowWidth = 200 WindowHeight = 200 open "" for window_popup as #gr
a = 0
timer 250, [t] wait
[t]
close #gr a = a + 10
if a<320 then
UpperLeftX = 10 UpperLeftY = a
WindowWidth = 200 WindowHeight = 200 open "" for window_popup as #gr
end if if a=310 then
close #gr timer 0 end if
wait
Regards,
code
|
|
|
Post by B+ on Nov 25, 2018 18:36:58 GMT
I don't know what use _popup Type is, can't seem to print anything in it.
nomainwin UpperLeftX = 100 UpperLeftY = 10 WindowWidth = 200 WindowHeight = 200 open "" for window_popup as #gr 'print #gr, "Hello World." '?????????? not right timer 250, [t] wait
[t] timer 0 close #gr a = a + 10 if a<320 then UpperLeftX = 100 UpperLeftY = a WindowWidth = 200 WindowHeight = 200 open "" for text as #gr print #gr, "Hello World." timer 250, [t] else notice "Goodbye" end if wait
window_popup is supposed to be Text window that takes text commands?
EDIT: oops misread Help, it's a Window Type window, so probably needs a control to display text.
|
|
|
Post by Rod on Nov 25, 2018 18:42:28 GMT
No popup is just a frameless full screen window, you need to fill it with something. Most usually a graphicbox but you also need to offer a way for the user to CLOSE the window since the standard close icon does not exist. Its great for full screen games.
|
|
code
Member in Training
Posts: 74
|
Post by code on Nov 25, 2018 18:44:26 GMT
I guess that is a version issue... Do you know the best window shape(no title,no border)for the old version ? Regards,
code
|
|
|
Post by Rod on Nov 25, 2018 19:06:21 GMT
Well you could not do popup in v1 and I have only just realised popup is available in v2. So no, there is no alternative you will have a title bar and frame in v1. Good incentive to move to v2.
|
|