Skip to main content
Participating Frequently
March 10, 2010
Question

Non-selectable flow elements?

  • March 10, 2010
  • 1 reply
  • 1227 views

I am building an editor that can display line numbers. I have used a span element to show the line number at the beginning of each line. I don't want this flow leaf element to be selectable or editable as the rest of the textflow. I understand that I can change the selection format or selectability in general for the whole text flow, but I cannot see how I can do this for a specific flow element. Is this possible? If not, is this a planned feature? If again the answer is no, is there a work around?

I am using the latest stable build (4.0.0.13875) for Adobe Flex Gumbo.

Thanks a lot for your time and help.

This topic has been closed for replies.

1 reply

Adobe Employee
March 10, 2010

If you are trying to block partial selection of an element, so that you can select or none of it, we do not support that directly, but you can get it to work. First off, you need to mark the FlowElement that is not selectable with a user formatting property, so you can tell which ones are selectable and which ones are not. Then you need to prevent the partial selection of non-selectable FlowElements. There are two ways to go here. You can override the SelectionManager class, and provide your own SelectionManager that overrides selectRange and adjusts the range of the selection if necessary before calling super.selectRange. You would probably also need to override EditManager in the same way. It may also be possible to listen for the selectionChanged event and do the same thing from the listener, but I am not entirely certain this will work, given the recursive nature of the task.

- robin

saviesAuthor
Participating Frequently
March 13, 2010

Thanks for the answer. I've been trying to implement this by overriding the SelectionManager as you suggested. Preventing selection on a single line is straightforward. However, the span elements that I use to display line numbers is repeated at the beginning of each line in the textflow. Hence if one selects a range that contains multiple lines, I can't prevent the selection of these intermediate span elements since selectrange is based on start and end positions only.

Furthermore, overriding selectrange doesn't prevent the selection of these elements via arrow keys. The handler functions for key events are private, so I can't override their behavior.

Instead of interfering with the actual range selection, I'm wondering if it is possible to hide the selection of these spans. I have to implement customized edit behavior for my application anyhow, so I could ignore selected line number elements within my customized edit operations. This would require hiding the blinking cursor for mousedown events plus preventing highlighting of these span elements after selection is completed.

Is such an approach possible? feasible? Or would you have any other suggestions on how I could proceed with this problem?

Thanks again for your time.

Adobe Employee
March 17, 2010

You can override the operations to skip over your line numbers. Getting the selection to skip over them is harder.

Why do you want the line numbers as part of the TextFlow? Wouldn't it be better to have them in a separate pane that goes beside the text? You have to scroll them both in sync, but that seems much easier and cleaner. You could watch for the scroll events from the TextFlow, and scroll the other pane with the line numbers to match.

Would that fit in your design?

- robin