PDA

View Full Version : Listbox controls.... aaaargh!



fxnut
09-10-2003, 08:05 AM
Hi guys,
Has anyone figured out how to stop a list box allowing a user to select more than one item from the list at once? I feel like a guy with a steering wheel in his lap (i.e. it's driving me nuts :rolleyes: ).

I've tried using the various event UDFs but with no luck as yet. Any ideas anyone?

Andy

Tom Speed
09-10-2003, 08:57 AM
Don't think that's possible at the moment. Just make the user aware that multiple selections are not taken into account before using your script.

Tom

bakasaru
09-10-2003, 09:57 AM
I've used the select_udf with some success wherein I return 'true' to allow an item to be selected only when 'getvalue' returns 'nil' or 'getvalue' == 'index' of the item being selected, else return false to prevent CTRL/SHFT selections.



Hope this helps

fxnut
09-10-2003, 10:08 AM
Bakasaru you're a star :D

Yep, that works great - and it's such a simple and elegant solution too. I guess the only problem is that it sometimes allows for no items to be selected, but that's not too much of a concern for me.

Actually, I've just managed to find another way of doing it which involves using the Idle_UDF that you can specify to the reqpost() call. I make my Idle_UDF check to see how many items were last passed to the Event_UDF of the list box, and if it's greater than one it sets the value of the listbox to the last value selected. This does prevent there being no items selected, but the listbox has a nasty tendency to flicker with all the rapid selection that's happening.

FYI, I'll be using your solution :) Thanks very much for your help.

Andy

bakasaru
09-10-2003, 10:13 AM
Glad that helped!:)

I also fiddled with reqkeyboard to trap for CTRL and SHFT keys, but it found the select_udf a little cleaner.


Enjoyed your site and your latest scripts btw!!

Cheers