Roger Guay wrote:

> What I discovered is that a field (used for another feature) in my
> rTools general catchall plugin butts in and prevents this code from
> seeing the selectedText of the topStack. Indeed, if a paste a field
> in your TextToolBar stack (which I love, BTW), your stack fails as
> well. And the solution . . . wait for it . . . use the ol Richard
> Gaskin maneuver and set the TraversalOn of the field to false.
>
> Thanks again, Richard!

Glad that worked out. I've made many authoring environments over the years, and have come to rely on being able to turn off traversalOn to allow tool palettes to work on text selections. If that fell victim of a regression I'd need to know about it ASAP; very glad to hear it didn't.

If it helps, as much as I like the idea of having a property name associated with me like a sort of Poirot mystery, the role of traversalOn there is understandable once we take a moment to examine what it is and how it works:

The traversalOn property (another woefully-named holdover from another time - why not simply "traversal", or better yet "focusable"?) allows you to traverse controls via the keyboard.

When I was doing Mac-only work the value of this was lost on me, as Mac in general is very mouse-dependent. But as I've spent more time using Windows and Linux and watching other such users in action I've come to appreciate that many people rely on being able to choose whether to use the mouse or stay on the keyboard when doing anything in a window.*

When buttons have traversalOn set to true, we can tab to them just as we'd tab between text fields, using the Enter key to trigger them. Powerful stuff, esp. with forms as your hands never need to leave the home row to reach for the mouse.

But focus is, quite rightly, limited to one control at a time. This allows us to anticipate which control our keyboard actions will affect.

So when a button becomes focused, any focus on other controls is gone. That includes any selection in field text. Think of focus on a button being similar to openField in a field. And just like a field, whether you tab into it or click into it, either way the gesture will move focus to that object.

While I do believe it can be very useful to support traversal as widely as practical, fortunately palette toolbars are a case where users don't expect to be able to tab between buttons. So there we can safely turn off traversalOn, and with that text selections remain preserved even when the button is clicked.



Side note:

This reminds me of a request for something we see in other programs, perhaps even supported in modern OS APIs, but not (yet) built into LiveCode:

Indication of selected text not currently in focus
http://quality.livecode.com/show_bug.cgi?id=3327

While toolbar buttons are easily doable, there are times when we may want to have focus on one field while maintaining a visual representation of selected state in another, with a means of addressing that secondary selection.

For example, consider an HTML editor in which you select a run of text and then enter a URL in a toolbar field as the URL to be inserted as a link in that selection.

We can work around this by setting (and later clearing) the backgroundColor of the selection, but it's a bit non-obvious to work out and might benefit from having some means of optionally preserving selection when focus is moved to another field.

The trick there is the syntax. We definitely don't want "the selection" or "selectedChunk" to refer to the previous selection, and something like "secondarySelection" and "secondarySelectedChunk" sounds insane.

If any of you have suggestions for ways to implement support for preserving secondary selection feel free to add them to that enhancement request.




* As useful as it is to deliver fully traversable UIs for our Windows custoemrs, unfortunately the current implementation of option controls does not allow us to support that at this time - see:
http://quality.livecode.com/show_bug.cgi?id=5505
http://quality.livecode.com/show_bug.cgi?id=2650

And for completeness, related:
http://quality.livecode.com/show_bug.cgi?id=13068

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 ____________________________________________________________________
 ambassa...@fourthworld.com                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to