Page 1 of 1

Combobox Disappears temporarily after Minimize

Posted: Tue Mar 28, 2023 1:43 pm
by matalog
I was trying to adjust a program to show the problem I am having where the Comboboxgadget will disappear temporarily after minimizing, when restored it needs to be clicked on again to make it appear.

I came up with this, and it's a mess, but will help me to understand some things.

The program doesn't allow the Comboboxgadget to be used as it is, I can uncomment the line mentioned and that allows it to work, but either way it disappears after minimize and restore, until it is hovered over.

Why does setgadgetstate not allow this to work correctly? I need to use imagegadget, which creates an image gadget that is already created.

And why does the Comboboxgadget disappear, and how can I make it reappear after window restore?

Code: Select all

Enumeration
  #Menu_Escape
  #Menu_Space
  #Menu_Enter
  #Menu_W
  #Menu_C
  #Menu_E
  #Menu_P
  #Menu_O
  #Menu_A
EndEnumeration
entry.s =""

OpenWindow(0, 0, 0, 800, 800, "Combo After Minimize Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)
image=CreateImage(0, 800, 800)
ImageGadget(0, 0, 0, 800,800, ImageID(0))

AddKeyboardShortcut(main, #PB_Shortcut_Escape, #Menu_Escape)
AddKeyboardShortcut(main, #PB_Shortcut_Space, #Menu_Space)
AddKeyboardShortcut(main, #PB_Shortcut_Return, #Menu_Enter)
AddKeyboardShortcut(main, #PB_Shortcut_C, #Menu_C)
AddKeyboardShortcut(main, #PB_Shortcut_P, #Menu_P)
AddKeyboardShortcut(main, #PB_Shortcut_O, #Menu_O)
AddKeyboardShortcut(main, #PB_Shortcut_A, #Menu_A)

ComboBoxGadget(7, 20, 600, 150, 19, #PB_ComboBox_Editable)

StartDrawing(ImageOutput(0))
Box(0, 0, 800, 800, #White)

SetGadgetText(7,"Initial State")
Entry = GetGadgetText(7)
AddGadgetItem(7, 0, Entry)
SetGadgetState(7, 0)

DrawText(301+x*14,400,"Some Text",0,#White)
StopDrawing()
SetGadgetState(0, ImageID(0))
;ImageGadget(0, 0, 0, 800, 800, ImageID(0))              ; If I uncomment the code on this line it works

Repeat
  
  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_Menu
      Select EventMenu()
          
        Case #Menu_C
          
        Case #Menu_O
          
        Case #Menu_P
          
        Case #Menu_Escape
          quit=#True
          
        Case #Menu_Space
          
        Case #Menu_Enter
          Entry = GetGadgetText(7)
          
      EndSelect
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      Select EventGadget        
          
      EndSelect
    Case #PB_Event_CloseWindow
      Quit=#True
  EndSelect
Until quit=#True Or Event = #PB_Event_CloseWindow


Thanks for any help.

Re: Combobox Disappears temporarily after Minimize

Posted: Tue Mar 28, 2023 2:52 pm
by Demivec
From your example code it looks like the combobox and the image gadget overlap:

Image gadget is at (0, 0) and contains an image 800 x 800.
Combobox is at (20, 600) and is 150 x 19.


Don't overlap gadgets. You can also try disabling the image gadget.

Re: Combobox Disappears temporarily after Minimize

Posted: Tue Mar 28, 2023 4:40 pm
by matalog
Demivec wrote: Tue Mar 28, 2023 2:52 pm From your example code it looks like the combobox and the image gadget overlap:

Image gadget is at (0, 0) and contains an image 800 x 800.
Combobox is at (20, 600) and is 150 x 19.


Don't overlap gadgets. You can also try disabling the image gadget.
Yes, that is the problem, thanks. If I want to draw behind the comboboxgadget, can I use a windowed screen without affecting the gadgets?

Re: Combobox Disappears temporarily after Minimize

Posted: Tue Mar 28, 2023 4:55 pm
by matalog
I tried drawing to the Window directly, why does the text disappear after the window is restored from minimised now?

Code: Select all

Enumeration
  #Menu_Escape
  #Menu_Space
  #Menu_Enter
  #Menu_W
  #Menu_C
  #Menu_E
  #Menu_P
  #Menu_O
  #Menu_A
EndEnumeration
entry.s =""
InitSprite()
OpenWindow(0, 0, 0, 800, 800, "Combo After Minimize Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget)


AddKeyboardShortcut(main, #PB_Shortcut_Escape, #Menu_Escape)
AddKeyboardShortcut(main, #PB_Shortcut_Space, #Menu_Space)
AddKeyboardShortcut(main, #PB_Shortcut_Return, #Menu_Enter)
AddKeyboardShortcut(main, #PB_Shortcut_C, #Menu_C)
AddKeyboardShortcut(main, #PB_Shortcut_P, #Menu_P)
AddKeyboardShortcut(main, #PB_Shortcut_O, #Menu_O)
AddKeyboardShortcut(main, #PB_Shortcut_A, #Menu_A)

ComboBoxGadget(7, 20, 600, 150, 19, #PB_ComboBox_Editable)

StartDrawing(WindowOutput(0))

Box(0, 0, 800, 800, #White)

SetGadgetText(7,"Initial State")
Entry = GetGadgetText(7)
AddGadgetItem(7, 0, Entry)
SetGadgetState(7, 0)

DrawText(301+x*14,400,"Some Text",0,#White)
StopDrawing()
;SetGadgetState(0, ImageID(0))
;ImageGadget(0, 0, 0, 800, 800, ImageID(0))              ; If I uncomment the code on this line it works

Repeat
  
  Event = WaitWindowEvent()
  
  Select Event
      
    Case #PB_Event_Menu
      Select EventMenu()
          
        Case #Menu_C
          
        Case #Menu_O
          
        Case #Menu_P
          
        Case #Menu_Escape
          quit=#True
          
        Case #Menu_Space
          
        Case #Menu_Enter
          Entry = GetGadgetText(7)
          
      EndSelect
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      Select EventGadget        
          
      EndSelect
    Case #PB_Event_CloseWindow
      Quit=#True
  EndSelect
Until quit=#True Or Event = #PB_Event_CloseWindow



Re: Combobox Disappears temporarily after Minimize

Posted: Tue Mar 28, 2023 5:22 pm
by PeDe
Hello matalog,

you can use a CanvasGadget as a container. What you draw into it will be buffered.

Peter

Code: Select all

...
CanvasGadget(8, 0, 0, 800, 800, #PB_Canvas_Container)
ComboBoxGadget(7, 20, 600, 150, 19, #PB_ComboBox_Editable)
CloseGadgetList()

;StartDrawing(WindowOutput(0))
StartDrawing(CanvasOutput(8))
...

Re: Combobox Disappears temporarily after Minimize

Posted: Wed Mar 29, 2023 8:24 pm
by matalog
Thanks for the help guys.

Just out of interest. If I wanted to have an imagegadget 300x300, somewhere on top of the canvasgadget 800x800, just so that the image could be saved to file, is that possible or will it collide with the canvasgadget?

Re: Combobox Disappears temporarily after Minimize

Posted: Wed Mar 29, 2023 9:06 pm
by infratec
As written before: overlapping of gadgets is not (official) supported.

You can open a borderless window with the imagegadget inside.
A window can always be on top of gadgets.

Re: Combobox Disappears temporarily after Minimize

Posted: Thu Mar 30, 2023 8:11 am
by Caronte3D
I use overlaping gadgets everytime, and I found a way to show it correct is with containers, if you put a gadget in a container, the that container can be over other gadgets.
Not the best way and maybe not for all, but a workaround :wink: