-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi All,
Consider the following situation:
I have a Textbox for defining item's description and a search button to allow the user searching for items with similar description (so far it is like a bandbox). I want to allow the user to select part of the text and when the search button is pressed do the search according to the selected text (if no text selected then search using the Textbox value).
Here is the problem:
1. Textbox does not have a getSelectedtext method.
2. If I use the "OnSelection" event to store the selected text I have a different problem (there is no clear selection event, at least I did not see any).
This cause problem in the following scenario:
1. Select some text (the "onSelection" event store the selected text.
2. Select a different component.
3. Use the mouse to re-select the description Textbox (The selection is cleared and no event fired so the stored selection text has value, but there is actually no selection).
Please advise,
Hanan.
http://docs.zkoss.org/wiki/Component_Events
look for "onSelection" (roughly 1/3 down the page)
Using the getStart and getEnd methods it mentions, you can parse what is currently in the textbox, and retrieve the selected text.
Hopefully that at least helps some.
And to be honest, I've never used it... so I don't know how well it will work for what you want...
Hi James,
Thanks for your answer, but as I said, I tried using it and there is a problem since there is no event when the selection is cleared. In that case the user does not see any selection, but I have the previous selection save and this is what I am using (if there was a clear event then I could use it to mar that there is no selection).
Regards,
Hanan.
@HananW,
The browser seems not to fire an event when user clear the selection.
@Frik,
You issue looks like another question, not for the text selection.
Asked: 2009-03-09 13:46:17 +0800
Seen: 716 times
Last updated: May 27 '11