Combobox Disappears temporarily after Minimize

Just starting out? Need help? Post your questions and find answers here.
matalog
Enthusiast
Enthusiast
Posts: 165
Joined: Tue Sep 05, 2017 10:07 am

Combobox Disappears temporarily after Minimize

Post 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.
User avatar
Demivec
Addict
Addict
Posts: 4085
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Combobox Disappears temporarily after Minimize

Post 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.
matalog
Enthusiast
Enthusiast
Posts: 165
Joined: Tue Sep 05, 2017 10:07 am

Re: Combobox Disappears temporarily after Minimize

Post 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?
matalog
Enthusiast
Enthusiast
Posts: 165
Joined: Tue Sep 05, 2017 10:07 am

Re: Combobox Disappears temporarily after Minimize

Post 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


PeDe
Enthusiast
Enthusiast
Posts: 119
Joined: Sun Nov 26, 2017 3:13 pm
Location: Vienna
Contact:

Re: Combobox Disappears temporarily after Minimize

Post 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))
...
matalog
Enthusiast
Enthusiast
Posts: 165
Joined: Tue Sep 05, 2017 10:07 am

Re: Combobox Disappears temporarily after Minimize

Post 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?
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Combobox Disappears temporarily after Minimize

Post 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.
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Combobox Disappears temporarily after Minimize

Post 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:
Post Reply