0

Strange behavior for shift+leftclick in Listbox component since ZK 5.0.7

asked 2011-06-27 12:54:27 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

Hey, since the upgrade to 5.0.7 I have a very weird behavior for the listbox component.

Let's say, I have a listbox with 5 rows, like this:

Row 1
Row 2
Row 3
Row 4
Row 5

Now, I click Row 2 and it gets highlighted:

Row 1
Row 2
Row 3
Row 4
Row 5

Now, I hold shift and click on row 4. I would now expect row 2-4 to be highlighted, but instead this happens:

Row 1
Row 2
Row 3
Row 4
Row 5

What's going on here?

I am on Mac OS X Snow Leopard with Google Chrome 12.
Same issue with Firefox on Mac and Chrome on Windows.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-06-27 13:33:04 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

Hi,

I've just tried this demo with Google Chrome and Firefox (both on Linux) and it works fine for me:

http://www.zkoss.org/zkdemo/listbox/multiple_selection

Can you reproduce the issue with the demo?

Cheers, Maik

link publish delete flag offensive edit

answered 2011-06-27 13:43:53 +0800

valmar gravatar image valmar
925 2 13
http://www.timo-ernst.net

I think I found the cause of the problem but I can't nail it down.

I registered the ON_CLICK event for all listitems like this:

		listitem.addEventListener(Events.ON_CLICK,
			new MessageHeaderSelectedEventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					if (event instanceof MouseEvent) {
						MouseEvent mouseEvent = (MouseEvent) event;

						// Don't open the message if shift, ctrl or right mouse button was used
						int pressedKey = mouseEvent.getKeys();
						if (ignoreKeysPressed(pressedKey)) {
							return;
						}

						// Get the message behind the event
						CachedMessage message = eventToMessage(mouseEvent);

						// Get the listitem which got clicked
						Component target = mouseEvent.getTarget();
						Listitem item = null;
						if (target instanceof Listitem) {
							item = (Listitem) target;
						}

						// Display the message
						handleMessageSelect(message, item,
							mailheadlistbox_div_root.getParent());
					}
				}
			});

I first thought that I accidently overwrote the default behavior but if that would be the case, multiple selection wouldn't work at all, wouldn't it? But instead it's just not working properly.

Also, I have a very similar problem with the ON_OK event.
I want a specific function to be called when the user selects a listbox item with the UP and DOWN arrow keys and then presses ENTER.
So, I added the event like this:

		listitem.addEventListener(Events.ON_OK,
			new MessageHeaderSelectedEventListener() {
				@Override
				public void onEvent(Event event) throws Exception {
					if (event instanceof KeyEvent) {
						KeyEvent keyEvent = (KeyEvent) event;

						// Get the message behind the event
						CachedMessage message = eventToMessage(keyEvent);

						// Get the listitem which got clicked
						Component target = keyEvent.getTarget();
						Listitem item = null;
						if (target instanceof Listitem) {
							item = (Listitem) target;
						}

						// Set the message
						handleMessageSelect(message, item,
							mailheadlistbox_div_root.getParent());
					}
				}
			});

The strange thing is: Now the UP and DOWN keys don't work any more.

If I remove all custom event listeners, then everything works alright...

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-06-27 12:54:27 +0800

Seen: 104 times

Last updated: Jun 27 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More