[Gambas-user] Empty ComboBox are filled while scrolling mouse without key press (gb.qt5)

T Lee Davidson t.lee.davidson at gmail.com
Mon Oct 2 16:21:30 CEST 2023


On 10/1/23 23:38, Safiur Rahman wrote:
> Also setting the ComboBox to ReadOnly while the mouse cursor is over it makes no difference because you can still change text of 
> ReadOnly ComboBox with mouse wheel scroll.

You are right. I previously thought it was just scrolling through the list values but leaving the actual ComboBox value 
unchanged. It appeared that way because setting ComboBox.ReadOnly back to False resets the Index to either 0 or -1.

The changing of the Index and the resetting of the Index can both be reverted with the help of a semaphore:
[code]
' Gambas class file

Private $iLastIndex As Integer

Public Sub Form_Open()

   ComboBox1.List = ["", "aa", "bb", "cc", "dd", "ee"]

End

Public Sub ComboBox1_Enter()

   ComboBox1.ReadOnly = True

End

Public Sub ComboBox1_Leave()

   ComboBox1.ReadOnly = False
   ComboBox1.Index = $iLastIndex

End

Public Sub ComboBox1_Change()

   $iLastIndex = ComboBox1.Index

End

Public Sub ComboBox1_MouseWheel()

   ComboBox1.Index = $iLastIndex

End
[/code]


-- 
Lee



More information about the User mailing list