|
Post by SunBurnt on Aug 9, 2011 2:44:12 GMT 1
Here`s a rewrite of a little diddy I did in Visual Basic about 15 years ago. V. B. can control the placement of a window, HUG at least can`t do it. So I elected to make the window big and to move the button around on it. It`s should to move the button randomly whenever the cursor comes close.
INCLUDE "/usr/share/BaCon/hug_imports.bac" INIT
winW = 600 : winH = 400 btnW = 120 : btnH = 25 btnL = 300 : btnT = 200 areaX = (winW - btnW - 5) areaY = (winH - btnH - 5)
SUB MOVE newL = RANDOM(areaX) + 5 newT = RANDOM(areaY) + 5 ATTACH( winMain_, btnClose_, newL, newT ) END SUB
SUB TEST X = GETX IF X > btnL - 10 AND X < btnL + btnW + 10 THEN MOVE Y = GETY IF Y > btnT - 10 AND Y < btnT + btnH + 10 THEN MOVE END SUB
winMain_ = WINDOW( "Busy Bozo", winW, winH )
btnClose_ = BUTTON( "Quit If You Can...", btnW, btnH) ATTACH( winMain_, btnClose_, btnL, btnT ) CALLBACK( btnClose_, QUIT )
TIMEOUT(500, TEST) DISPLAY
I`m not sure if my math code is correct in the 2 subs and just above them. It has sporadically moved the button, but it doesn`t do what I want. ( What a surprise...)
|
|
|
Post by Pjot on Aug 25, 2011 14:43:06 GMT 1
Hi Sunburnt, Thanks for your code, but unfortunately this approach is not working. The GETX and GETY functions assume an ANSI compliant terminal and return the actual position of the cursor. Your program appears to need the position of the mouse. In HUG there is a MOUSE function but this assumes the presence of a canvas. In other words: your idea better can be implemented using GTK directly... Best regards Peter
|
|