Canvas with controls on top (z-order)
Posted: Sat Nov 30, 2024 6:51 am
Briefly, I've got a canvas that that fills the window. On top of the canvas, I am placing buttons (and later other controls, including canvas controls). I am drawing content on the canvas and the expectation is that the controls to remain visible and functioning.
If I create the background first then a button, I can see the button (looks perfect) but cannot get to respond to a click.
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
drawLogo ( 0 )
then
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
If I reverse the creation order
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
then
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
drawLogo ( 0 )
I cannot see the button but it responds to click events. Ah, but I can tab between them which changes the state invalidates and redraws.
(Of course, if I get rid of the background, the buttons work as expected.)
I just did another test. I removed the drawLogo from the OpenWindow and added a two second timer and THEN called drawLogo. The program created a white canvas with the buttons added after the canvasGadget then two seconds later, the canvas was updated and drew over the buttons that were previously visible. Tabbing through the controls restores the visibility regardless of whether they are above or under the canvas but only the ones on top of the canvas respond to clicks.
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
buttonGadget ( #g_background_showHDMI, x1, y1, w1, h1, "HDMI", #PB_Button_MultiLine )
Is there a trick that I'm missing to handling control z-order or perhaps using the wrong functions ?
And if I may ask another semi-related question... in the OpenWindow, I'm using #pb_window_invisible
if openWindow ( wind, windowx, windowy, windoww, windowh, "", #PB_Window_Borderless | #PB_Window_Invisible, parent )
and then
setWindowPos_ ( windowID ( wind ), #HWND_TopMost, 0, 0, 0, 0, #SWP_NoSize | #SWP_NoMove | #SWP_ShowWindow )
I'm doing this because the routine, I'm watching the canvas being created and updated, which is causing a bit of flashing.
Is this the correct procedure to ensure the screen just appears in an instant ?
If I create the background first then a button, I can see the button (looks perfect) but cannot get to respond to a click.
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
drawLogo ( 0 )
then
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
If I reverse the creation order
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
then
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
drawLogo ( 0 )
I cannot see the button but it responds to click events. Ah, but I can tab between them which changes the state invalidates and redraws.
(Of course, if I get rid of the background, the buttons work as expected.)
I just did another test. I removed the drawLogo from the OpenWindow and added a two second timer and THEN called drawLogo. The program created a white canvas with the buttons added after the canvasGadget then two seconds later, the canvas was updated and drew over the buttons that were previously visible. Tabbing through the controls restores the visibility regardless of whether they are above or under the canvas but only the ones on top of the canvas respond to clicks.
buttonGadget ( #g_background_config, x1, y1, w1, h1, "Config", #PB_Button_MultiLine )
canvasGadget ( #g_background_logo, 0, 0, windowW, windowH )
buttonGadget ( #g_background_showHDMI, x1, y1, w1, h1, "HDMI", #PB_Button_MultiLine )
Is there a trick that I'm missing to handling control z-order or perhaps using the wrong functions ?
And if I may ask another semi-related question... in the OpenWindow, I'm using #pb_window_invisible
if openWindow ( wind, windowx, windowy, windoww, windowh, "", #PB_Window_Borderless | #PB_Window_Invisible, parent )
and then
setWindowPos_ ( windowID ( wind ), #HWND_TopMost, 0, 0, 0, 0, #SWP_NoSize | #SWP_NoMove | #SWP_ShowWindow )
I'm doing this because the routine, I'm watching the canvas being created and updated, which is causing a bit of flashing.
Is this the correct procedure to ensure the screen just appears in an instant ?