[Gambas-user] Combobox, How to get back to old Auto-list-width-behaviour ?

Benoit Minisini benoit.minisini at gambas-basic.org
Fri May 27 15:51:43 CEST 2022


Le 27/05/2022 à 10:14, ub2 at gmx.ch a écrit :
> Dear Gambas Cracks
> 
> 
> I'm fiddling in vain since ... I'd like to ask for some hints.
> 
> The Situation (example):
> I have a combobox.w = 75
> - containing a list of entries some of them with length >>> 75
> - the list is filled on runtime, Examples:
> 1  skdjhlkdsf ndsklgjslkn ksrhgsk
> 2  dsfkf sdfgs f hsdfhs sdf gsdf sd
> 3  asdgfs dsfh sdhf sdhb
> 4  ...
> 
> The user then selects an entry,
> the code cuts selected entry down to "first column"
> and saves it to Combobox.text
> which fits perfect into combobox.w = 75
> 
> 
> With older Combobox-Versions (?qt4?):
> -The List blew up in width to fit to widest list entry,
> -- if required even bigger than Form.width !
> -- Combobox itself remained in place and size.
> 
> 
> With Gambas 3.17.2, gb.qt5, Xub20.04LTS
> - The combobox."Listwidth" remains at combobox.w
> - The list entries are stripped down to fit into
> -- 1  s...hgsk
> -- 2  d...f sd
> -- 3  a...sdhb
> -- ...
> With longer entries Combobox becomes useless.
> 
> 
> Is there a property to get back to old "combobox.ListAutoFitWidth" 
> behaviour ?
> 
> 
> Following workaround does not really satisfy:
> 
> Public Sub Cbo_Enter()
>          Dim $Add_W_Int$ As Integer
> 
>          $Add_W_Int$ = +300
> 
>          Cbo.w = Cbo.w + $Add_W_Int$
>          Cbo.x = Cbo.x - $Add_W_Int$
> End
> 
> Public Sub Cbo_Leave()
>          Dim  $Add_W_Int$ As Integer
>      Dim $x$ As String
> 
>          $Add_W_Int$ = -300
> 
>          Cbo.w = Cbo.w + $Add_W_Int$
>          Cbo.x = Cbo.x - $Add_W_Int$
>          Cbo.Refresh
> 
>          $x$ = Cbo.text
>          Cbo.text = Left($x$, InStr($x$, " ") - 1)
> 
> End
> 
> 
> Any good ideas ?
> 
> Thanks ub2
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

The old behaviour has been mimic in the last commit.

Beware that it should not work on Wayland, as Wayland does not allow to 
position a window (the combo popup in that case) where you want on the 
screen.

Regards,

-- 
Benoît Minisini.


More information about the User mailing list