Page 1 of 1

When resizing the window, the text is highlighted

Posted: Mon Mar 04, 2024 3:04 am
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

Re: When resizing the window, the text is highlighted

Posted: Mon Mar 04, 2024 4:27 am
by tua
Strange - definitely tied to the #PB_ComboBox_Editable flag. If you remove it from the comboboxes, this does not happen...

Re: When resizing the window, the text is highlighted

Posted: Mon Mar 04, 2024 4:44 am
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

Re: When resizing the window, the text is highlighted

Posted: Mon Mar 04, 2024 5:11 am
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

Re: When resizing the window, the text is highlighted

Posted: Tue Mar 05, 2024 5:51 pm
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