|
Post by davidk64 on Jun 7, 2022 7:38:46 GMT
dim buttonLabels$(6,6)
for row = 0 to 5
for col = 0 to 5
buttonLabels$(row, col) = " "
buttonHandleName$ = "#cell." + str$(row) + str$(col)
cellPosX = 5 + col * 20
cellPosY = 5 + row * 20
button #buttonHandleName$, " ", handleCellClick, UL, cellPosX, cellPosY
next col
next row
WindowWidth = 500 : WindowHeight = 500
open "Testing button click" for window_nf as #cell
wait
sub handleCellClick buttonhandle$
notice buttonhandle$
end sub
wait
close #cell
end
In the HTML help on "Handle Variables" in the "GUI Programming" section it seems to imply I can create buttons dynamically? But when I run the code I don't get any buttons. I'm wondering if the use of the handle variable is only for manipulating statically declared buttons? I admit the samples don't show dynamic creation of buttons ... I was just hoping!
|
|
|
Post by tsh73 on Jun 7, 2022 8:04:10 GMT
Hello David Yes you cannot dynamically create buttons. By manipulated things what were declared statically you can get pretty far like for example justbasiccom.proboards.com/thread/763/magic-square(and bunch of other letter games/color balls variety games) but having dynamically creation possible would be handy indeed.
|
|
|
Post by davidk64 on Jun 7, 2022 10:17:09 GMT
Thanks for the unwelcome answer So thinking about it there is no compiler error because the code is valid albeit flawed with regard to intent. I define a button with the same handle "#buttonHandleName$" over and over just changing the x/y offsets each time. Then when the window is opened there is no button associated with it because "#cell" doesn't link to "#buttonHandleName$". Wondering whether "#buttonHandleName$" is a valid #handle name though. Help says it must be alphanumeric and this has "$" character in it? Also interesting that you can dynamically open multiple windows by "create handles dynamically on the fly" as described in the MAPHANDLE help topic!
|
|