How to control cursor (carat) position in TextInput in Flex 4.5 - apache-flex

I need to handle diagraphs and then convert them on the fly to the proper unicode representation. For example when the user types in:
Sx
My app needs to replace it with:
Ŝ
Now, I've been able to do the replacement no problem. The issue though is that once I've done the replacement, the cursor goes to the beginning of the textbox rather than the end. As I'm trying to update the user's text on the fly, this obvious doesn't work.
How can I get it so that once I replace the text in the TextInput box, the cursor is on the right hand side rather than the left?

Found a solution.
All you have to do is instead of updating the whole text, wipe the current content and then use:
textInput.appendText()
Hopefully this will help someone else :)

The setSelection method is how you set the cursor
textInput.setSelection(textInput.text.length, textInput.text.length);
You can get the current beginning of the selection with TextInput.selectionAnchorPosition and the end of the selection with TextInput.selectionAnchorPosition

Take a look at this SO Question: How do you programmatically move the caret of a Flex TextArea to the end?
If you are using a textArea then this will work (from the selected answer):
textArea.selectionBeginIndex = textArea.length;
textArea.selectionEndIndex = textArea.length;

For the people coming here for the solution for the Spark textInput, this is the way:
textInput.selectRange(textInput.text.length, textInput.text.length);

Related

How to display ipywidgets.Dropdown without a value selected

No question anymore. The problem is older ipywidgets version behaviour that looks to be fixed in version 7.
The ipywidgets.Dropdown on its own picks up the first value out of the options list.I would like to display the widget without a value selected.The first value in the list is a pointless default that still needs to be reflected down the workflow path. I read a discussion where a developer went as far as adding empty string item into the list. That fixes the dropdown look (to some extent though as the placeholder attribute is still ignored) but adds a silly selectable empty item to the dropdown list. Adding dummy "None" item to the list is not much better solution.Setting value to None results in the "Invalid selection" exception.I do not understand why the ipywidgets.Dropdown does not follow approach of the simpler widgets where empty value is allowed and placeholder text is dispalyed to prompt the user to select something.Is there a way to make the widget selection not required? Some attribute setting I am not aware of? If that is impossible then what is the simplest possible workaround?
You can just set the dropdown value to None:
import ipywidgets as widgets
d = widgets.Dropdown(options=['hello', 'world'], value=None)
d
in 'ipywidgets' version 7.2.1 you will need to disable user changes to be able to display the widget by setting it to False like this:
d = widgets.Dropdown(options=['hello', 'world'], value=None, disabled=False)

Flexicious - Close itemEditor

I got a very stupid problem which I just can't resolve : I want to close an item Editor in my FlexDataGrid from Flexicious.
Indeed, when I hit the Enter key, I enter my itemEditEndHandler function, but then the itemEditor don't close (however it close correctly when hitting Escape or Tab key). I was first thinking to use a method like datagrid.destroyItemEditor() (like with the common datagrid...) but there isn't any obvious methods or way to close it !!!
sadly, there isn't a lot of doc for the FlexDataGrid from Flexicious :'(
Did anybody already have meet this problem ? Do you know some good way to force the closing of the itemEditor ?
Thanks
Try grid.bodyContainer.endEdit(grid.bodyContainer.getCurrentEditor()).
We will add destroyItemEditor to the next release.

Emberjs CollectionView changes from 0.9.7.1 to 1.0.pre?

I had some code that connected an ArrayController with CollectionView that no longer works once I upgrade to 1.0.pre.
It seems that CollectionView no longer passes each element of the collection to its template view class?
I've distilled my issue to this jsFiddle: http://jsfiddle.net/chaodoze/CbwCN/
Notice it outputs to "1,2,3" on each line in 1.0.pre
In 0.9.7.1, it outputs correctly as a single digit on each line.
Am I doing something wrong here or is this a bug?
What is the best way to work-around this issue?
Thanks!
In 1.0.pre the view's context has changed. When you access {{content}} you are really accessing {{controller.content}}, which is [1,2,3]. You need to access the view's content, which in the individual number, that is done with {{view.content}}.
See http://jsfiddle.net/CbwCN/2/

How to change the state in Adobe Flex, using ActionScript?

I`m really new to Flex and ActionScript so please be patient with me.
I want to implement this script: tinyurl.com/yafqrqb
...that is doing this "magic" : tinyurl.com/y9qg32r
...but I want to tweak it a little on InfoWindowTabbedComponent. To be more precisely I`m trying to insert links in that tabs, and when you click one the state will change.
You can see my custom InfoWindowTabbedComponent at the end of the post As you can see, right now I have 2 functions that open url`s.
What I`m trying to do is to change this:
var adobeURL:URLRequest = new URLRequest("http://www.microsoft.com" );
navigateToURL(adobeURL, "_self");
Into something that change the current state.
Can you please help me?
Here`s my custom InfoWindowTabbedComponent: http://pastebin.com/f387bc3b9
I'm not sure I understand what you want to do. If you just want to set the selected Tab, instead of calling navigateToURL() set myTabNavigator.selectedIndex (or selectedChild)
If you really want to change the state, each component has a currentState property, but then you would have to define the states first (via the tag)
And if you really want to navigateToURL() you could navigate to javascript:somefunction() and then set the application state via ExternalInterface, but that would be horribly circumstantial.
Cheers,
Jörg

How to turn on line number tooltip while scrolling infragistics ultrawebgrid

I once saw this feature in action but I don't know how to turn it on. The grid can show a tooltip with the current row number (or row ID) while dragging the scrollbar. This helps you to stop the scroll in the right place. I'm assuming some property will turn this on, but I can't find it.
Maybe it is also dependent on the scroll mode?
UPDATE:
In the image below you can see an example of the tooltip I'm looking for. This is displayed while the scrollbar is being dragged (up or down). The number in the tooltip is the row number (you can't see it in this image, way to the left in the grid). This is the same grid that I am using now. Just from a very old build of our product. Somehow this tooltip was turned off. And no one knows how to turn it back on :(
I'm pretty sure this is a built in feature of the ultrawebgrid. Not something that required extra coding.
alt text http://img138.imageshack.us/img138/6337/croppercapture.jpg
Right! Now that we've established that you have version 6.3, I've hopefully got a solution for you. I don't have 6.3 myself, but I've got a slightly later one that I think didn't have Virtual Scrolling added as a feature yet.
So try this code:
webgrid.DisplayLayout.XmlLoadOnDemandType = XmlLoadOnDemandType.Virtual;
This should automatically put a tooltip on the grid as you scroll down. Have a look here for a running sample... (and remember to choose the virtual option)
Here's hoping!
Rob G
I don't know if there's a UltraWebGrid property to simply turn on the behavior you're looking for. I almost suspect you experienced this feature in another application, perhaps not even a web based one (sorry!). I do however, know exactly what you're talking about.
As a work-around, I would suggest allowing the user to input the destination row number, and to simply "jump" to it, using this technique.
If that doesn't satisfy you, it may be possible to achieve this behavior with JavaScript. You would need to use something like this technique to get the information you need, estimate (or actually detect, if possible) the row number, and the rest is up to the GUI. I would go with the work-around described above though :)
I'm typing this from memory here as I don't have it installed on this machine and I haven't seen that setting before, but how about adding something like this to the InitializeRow event:
foreach (UltraGridCell cell in e.Row.Cells)
{
if(cell.Column.Key == "Topic") //from your grid above
cell.Title = cell.Row.Index;
}
The row object itself does not have a "Title" property from memory, but the cell does.
See if that works...
Regards,
Rob G
OK - I think I've found your illusive setting:
You can set the TipStyleScroll on the Override to Show on the Grid (this may be version dependant).
You can determine which field is displayed as the tooltip by using the ScrollTipField property of the band.
I did it like so:
myGrid.DisplayLayout.Override.TipStyleScroll = TipStyle.Show;
myTopBand.ScrollTipField = "Id";
...and it works like a charm!
If it's a really long list, sometimes setting the ScrollStyle to Deferred helps:
myGrid.DisplayLayout.ScrollStyle = ScrollStyle.Deferred;
Hope that helps...
Rob G
Once again - not sure which version you have, so to be safe here's somthing you can try from 2009 version:
myGrid.Behaviors.VirtualScrolling.Enabled = true;
myGrid.Behaviors.VirtualScrolling.TooltipVisibility = DefaultableBoolean.True;
If your scrolling mode is Deferred instead of Virtual, then the tooltip is normally enabled by default.
You can find full details about this feature here
Hope that helps,
Rob G

Resources