How do I keep focus on TextBox after a button was pushed? - windows-phone-7

I have a XAML ListBox, a TextBox inside the ItemTemplate. A user edits text inside the TextBox, and then presses a button in the application bar. How do I keep the focus on the TextBox after the button in the application bar was pushed?

You don't. You set it back afterwards.
You can use Focus() method to do this.
You can also use the SelectionStart and SelectionLength to highlight a specific part of the text.

Related

Change the button color by onclick event using Animations in Xamarin.forms

I want to change the color of the button when a user clicks on it,the click event is bindable i.e., implemented in ViewModel....when the user clicks on the button some kind of animation has to be done so that the user can know his selection
There is a possibility to this by binding the button color and in the method I can change the colours..But I want to achieve it using Animations(FadeTo,FadeIn) from ViewModel
Is It possible to do like this??
Thank You

change ListView item image at runtime (firemonkey)

I need the ability for a user to press and set an ListView item's checkbox independently of clicking on the item. If they press on the checkbox I will add/remove the checkmark and take some action. If they press on the item text I can take another action.
I can do this with a ListBox no problem with built in functionality. I can't figure out how to do it with a ListView. How is it done?
I can put the following code in the ListView1ItemClickEx to know when the user is clicking on the image. Maybe I can just change the image to a checkmark?
if (ItemObject->Name == "I") {
ShowMessage("Item Image clicked");
}
But I don't know how to change that particular items image (e.g. I could just toggle between a checkmark image and an unchecked image) at runtime.
The picture below is for clarity. Clicking anywhere in the red box will change the items checkbox. For the ListBox clicking anywhere in the blue box will fire the OnClick event and not change the checkbox. I want that same behavior in the ListView.
Ok, Remy answered this related question and it helped me solve this issue. Now I can make the ListView have a checkbox that functions like that of the ListBox. I do it by toggling the item image whenever the user presses (or clicks on) the image area of an item.
When the user clicks an items image I trap it (per Remy's code in the ListView1ItemClickEx event) and toggle it from 0->1 or 1->0 in a vector at reference ItemIndex (e.g. myVector[ItemIndex] = 0) and then I completely rebuild the ListView (clear it and build from scratch).
I thought I'd have to remember where in the list I had scrolled down to and after refreshing the ListView I'd have to scroll to that point in code - but, that isn't the case. I don't know why but after the refresh I'm still at the point in the list where I clicked an item image. It makes it work and feel exactly like a check box.
It works great in iOS, Android, and Windows.
p.s. I forgot to mention that you need to treat any Header's like they are items in your vector that keeps up with each items' image (0 or 1). Otherwise adding headers gets you out of sync and clicking an item's image will toggle some other item's image.

JavaFX capture events of a disabled button

In my application I have a multi step form wizard in which
the next button is disabled unless all the required fields are entered.
Some fields require extra validation such as the directory picker,
for which I have to check whether the directory exists or not.
To ease the user experience I need to show an "Invalid directory" tooltip
next to the directory text field.
I would like to show the tooltips when the user tries to click/enter the disabled
next button.
Is it possible to capture events performed on a disabled button in JavaFX?
public void nextEntered(Event event) {
Button button = (Button)event.getSource();
if(button.isDisabled()){
validate(currentTab);
}
}
I had a similar problem where I wanted to show a tooltip of a disabled field's value when the user moused over that disabled field.
I ended up putting a blank label over the disabled field and attaching a mouse event to that.
In the case of a button, you can just give the dummy label mouse transparency when the button becomes enabled so the user can click the button.
(You might even be able to bind the label's mouse transparency property to the button's enabled property but I'm not sure.)
I know this was asked a year ago but maybe it will help someone else.

Kendo UI Toolbar and Grid - strange save behavior when triggered from Toolbar control

I have some pages where I have a kendo ui grid (wired up to full CRUD services), but use a separate Kendo UI Toolbar control (as opposed to the toolbar configuration in the grid itself). I have a number of different buttons/menus on the toolbar, but am seeing a strange behavior when calling saveChanges() on the grid. If a cell is being edited when the save button is clicked, the grid is saved, but the edited value is lost (it reverts back to where it was). The following details what I see in different situations:
When using a save button configured in the grid (command: "save"), any changes in a cell being edited are committed with the save.
When using a plain html button that calls the saveChanges() method of the grid, any changes in a cell being edited are committed with the save.
When using a save button configured in a toolbar control, the changes in a cell being edited are LOST when saveChanges() is called.
The following jsbin shows the behavior of all three:
http://jsbin.com/jazobexatu/2/edit?html,js,output
I have tried calling the save from the toolbar button a number of different ways (even trying to trigger the click event of the external button), but nothing seems to correct the behavior. I also tried calling closeCell() on the grid (to try to force the value back into the data, but that doesn't work either). I haven't been able to debug the javascript enough to figure out what is different. I'm hoping someone with a deeper understanding of these controls can help me out.
For some reason, the mouse down event on the toolbar button doesn't cause a blur on the editor.
You can try it yourself by clicking in the cell to edit it, then click and hold the mouse button down on the "normal" button. The editor closes on mouse down, causing a blur of the editor, and persists the change.
If you do the same thing, click and hold mouse down, on the toolbar button, the editor stays open.
I've been poking through the source, but haven't figured out exactly why this happens. My best guess would be that the mousedown handler on the toolbar prevents the event from bubbling or running its default action and the editor doesn't blur.
Additional detail: On mousedown on the grid header button and the normal button, the focused element changes (which is what causes the editor blur). But on mousedown of the toolbar button, the editor input element still has the focus.
Shifting the focus on mousedown of the toolbar might be a workaround.
Sort of a weird hack, but this works in Chrome (any should in any browser that supports activeElement
click: function (e) {
$(document.activeElement).blur();
$("#grid").data("kendoGrid").saveChanges();
}

How make button in NSWindow clickable while a sheet's on top of it

I have created a custom (themed) NSWindow, by creating a borderless window and then recreating all elements of the window border/background inside the content view. I've created the window widgets (close box, zoom box, minimize box) on top of my own fake title bar using -standardWindowButton:forStyleMask:.
Trouble is, when a sheet is presented on top of my custom window (e.g. "save changes...", those buttons do not receive the clicks.
Does anybody know how I can tell NSWindow not to intercept the clicks in my minimize box? It works with a standard NSWindow. When a sheet is up, I can still send both of them to the dock, or zoom the window out.
I thought maybe there's special code in the content view that ignores clicks in subviews while a sheet is up. But it seems as if -hitTest: is called on the content view and returns the minimize widget, but the widget's action never gets triggered.
I guess I could just replace the content view and perform the action in the content view's hitTest if it is the minimize widget ... but that seems a bit ugly.

Resources