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

T Lee Davidson t.lee.davidson at gmail.com
Sun Oct 1 23:53:20 CEST 2023


On 10/1/23 13:00, Safiur Rahman wrote:
> Is there a way to preserve ComboBox Text which is obtained by selecting an item  from pop up list or writing on it but deleting 
> the text which is filled just by mouse wheel scroll?

Not easily. In fact, I just tried to do that. Unfortunately, the Change and Click events don't distinguish between changes make 
by the keyboard and those made by the mouse. My code became quite convoluted, and I finally gave up.

> Is there a way to disable all events due to mouse wheel scroll ?

No. Not many native events can be stopped with "Stop Event", and apparently the MouseWheel event is one of those that cannot.

The only thing I can think you might do is set the ComboBox to ReadOnly while the mouse cursor is over it. This would, of 
course, prevent the user from clicking into the control to place the text cursor in the control for editing. If you include a 
blank list item at the top, the user could click on that and begin editing.

[code]
' Gambas class file

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

End
[/code]


-- 
Lee



More information about the User mailing list