When resizing the window, the text is highlighted

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 2226
Joined: Sun May 14, 2017 1:48 am

When resizing the window, the text is highlighted

Post by AZJIO »

When resizing the window, the text is highlighted. How to get rid of this?

Code: Select all

Procedure SizeHandler()
	Protected w, h
	w = WindowWidth(0)
	h = WindowHeight(0)
	ResizeGadget(0, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
	ResizeGadget(1, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
	ResizeGadget(2, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
	ResizeGadget(3, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
EndProcedure

If OpenWindow(0, 0, 0, 720, 600, "Resize the window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
    ComboBoxGadget(0, 5, 59, 557, 27, #PB_ComboBox_Editable)
    ComboBoxGadget(1, 5, 121, 557, 27, #PB_ComboBox_Editable)
	ComboBoxGadget(2, 5, 183, 557, 27, #PB_ComboBox_Editable)
	ComboBoxGadget(3, 5, 245, 557, 27, #PB_ComboBox_Editable)

	For c=0 To 3
		For i=0 To 7
			AddGadgetItem(c, -1, Str(i))
		Next
		SetGadgetText(c, Str(i - 1))
	Next
    
    BindEvent(#PB_Event_SizeWindow, @SizeHandler())

    Repeat
        Select WaitWindowEvent()
            Case #PB_Event_CloseWindow
                End
        EndSelect
    ForEver
EndIf
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: When resizing the window, the text is highlighted

Post by tua »

Strange - definitely tied to the #PB_ComboBox_Editable flag. If you remove it from the comboboxes, this does not happen...
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: When resizing the window, the text is highlighted

Post by BarryG »

Definitely related to #PB_ComboBox_Editable.

You can fake it in the meantime with a dirty hack like this:

Code: Select all

Procedure SizeHandler()
  Protected w, h
  w = WindowWidth(0)
  h = WindowHeight(0)
  For gad = 0 To 3
    t$ = GetGadgetText(gad)
    SetGadgetText(gad, "")
    ResizeGadget(gad, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
    SetGadgetText(gad, t$)
  Next
EndProcedure

If OpenWindow(0, 0, 0, 720, 600, "Resize the window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
  ComboBoxGadget(0, 5, 59, 557, 27, #PB_ComboBox_Editable)
  ComboBoxGadget(1, 5, 121, 557, 27, #PB_ComboBox_Editable)
  ComboBoxGadget(2, 5, 183, 557, 27, #PB_ComboBox_Editable)
  ComboBoxGadget(3, 5, 245, 557, 27, #PB_ComboBox_Editable)
  
  For c=0 To 3
    For i=0 To 7
      AddGadgetItem(c, -1, Str(i))
    Next
    SetGadgetText(c, Str(i - 1))
  Next

  BindEvent(#PB_Event_SizeWindow, @SizeHandler())
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: When resizing the window, the text is highlighted

Post by RASHAD »

Code: Select all

	For c=0 To 3
		For i=0 To 7
			AddGadgetItem(c, -1, Str(i))
		Next
		SetGadgetState(c, i - 1)
	Next
Egypt my love
User avatar
Michael Vogel
Addict
Addict
Posts: 2820
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: When resizing the window, the text is highlighted

Post by Michael Vogel »

And another workaround...

Code: Select all

Procedure SizeHandler()
	Protected w, h
	w = WindowWidth(0)
	h = WindowHeight(0)
	a=GetActiveGadget()
	For i=0 To 3
		SetActiveGadget(i)
		ResizeGadget(i, #PB_Ignore, #PB_Ignore, w-41, #PB_Ignore)
	Next i
	SetActiveGadget(a)
	
EndProcedure

If OpenWindow(0, 0, 0, 720, 600, "Resize the window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
	ComboBoxGadget(0, 5, 59, 557, 27, #PB_ComboBox_Editable)
	ComboBoxGadget(1, 5, 121, 557, 27, #PB_ComboBox_Editable)
	ComboBoxGadget(2, 5, 183, 557, 27, #PB_ComboBox_Editable)
	ComboBoxGadget(3, 5, 245, 557, 27, #PB_ComboBox_Editable)

	For c=0 To 3
		For i=0 To 7
			AddGadgetItem(c, -1, Str(i))
		Next
		SetGadgetText(c, Str(i - 1))
	Next

	BindEvent(#PB_Event_SizeWindow, @SizeHandler())

	Repeat
		Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			End
		EndSelect
	ForEver
EndIf
Post Reply