I'm having five Image Buttons. If a button was clicked by mouse, then the button went to Onstate. Now if i pressed Space button it will zoom the button's image in a seperate Window.
The space button should not work when the button id in OFFstate. now can i trigger the Keyevent? i already referred Quicklook and working on that. any new ideas?
You don't need to trigger the key event, just respond to it as though it were any old method call from the button. After giving it a target and a selector, give it a key equivalent of #" " and respond to the key press accordingly:
- (void)someAction:(NSButton*)sender event:(NSEvent*)event {
//...
if ((sender.state == NSOnState) && (event.keyCode == 0x32)) {
//Zoom
}
//...
}
Related
I am trying to change the UITextView keyboard return button in to Done button.
I need to close the keyboard when I press the Done button.
I have create a UITextView and change the return button in to Done button.
This is my code
PhotoTitle = new UITextView
{
TranslatesAutoresizingMaskIntoConstraints = false, Editable = true, AccessibilityIdentifier = "PhotoTitle",
ReturnKeyType = UIReturnKeyType.Done
}
The keyboard showing Done button successfully. if I press it just behave like return button.
And I can not find a particuler event for fire when tap on Done button.
First of all you have to keep remember that, UITexiView is a scrollable UI widget. So, when you change the keyboard's default Return key in to Done button, you are hiding the opportunity of go to new line inside your UITextView. Therefore my suggestion is, if you are using a UITextView and you need a Done button by keeping the default keyboard, you should add a UIToolBar on top of the keyboard where you can place the Done button.
Since I'm not aware of your real need, which may do not need go to a new line and just need to exit the keyboard when user tap on the Return/Done button, here how you need to do it.
public override void ViewDidLoad()
{
base.ViewDidLoad();
TextView.WeakDelegate = this;
}
[Export("textView:shouldChangeTextInRange:replacementText:")]
public bool ShouldChangeText(UITextView textView, NSRange range, string text)
{
if (text.Equals("\n"))
{
TextView.ResignFirstResponder();
return false;
}
return true;
}
That is quite easy actually subscribe to the ShouldReturn event of the UITextField with a delegate or anonymous method that will call ResignFirstResponder on the field.
You can check this example project that shows how to do it
this.txtDefault.ShouldReturn += (textField) => {
textField.ResignFirstResponder();
return true;
};
Can we override navigation back button pressed in Xamarin.forms?
I have one navigation back button and the one save button in navigation bar.Save button hits the web service and saves in asynchronous way. While saving although i used progressing bar, navigation back button can be pressed and hence the app crashes due to index out of range exception on navigation stack.I tried using OnDisappearing() , did not work. I wanna cancel the PopUpAsync(),if the save is not done completely, but failed to achieve that. Is there any solution for this scenario? Can we override the navigation back button press event using any custom renderer ?
For controlling the back button to do what I want, I used this method in Xamarin:
public override bool OnKeyDown(Keycode HWkeyCode, KeyEvent e)
{
if (HWkeyCode == Keycode.Back)
{
StartActivity(typeof(FrontPageActivity));
return true;
}
return false;
}
I want to fire an event when I am done editing a UITextField. I.e., when the user presses the return key. Currently the event can only be fired off by pressing a button I have on the main storyboard. Is it possible to fire this event off by pressing the enter or return button?
this.txtDefault.ShouldReturn += (textField) => {
// fire even or call method here
return true;
};
I have a TextArea, and have been set a handler for the scroll event:
myTextarea.setOnScroll((event) -> {
System.out.println("setOnScroll: " + event);
});
But I found when the text in the textarea are very long, and if I put my mouse on it and scroll the mouse wheel, it doesn't print the event!
Only if the text reaches to the end, it starts to show the event.
I also tried setOnScrollStarted, and setOnScrollFinished, the same situation happens.
How to capture each scroll event in JavaFX?
Finally I found the solution:
myTextarea.addEventFilter(ScrollEvent.ANY, (x) -> {
System.out.println("scrolled");
});
Seems a little strange to use the method addEventFilter, but it works.
I'm having trouble getting ScrollViewer with item-bound text boxes to scroll when the keyboard is up. I'm also clueless about enumerating the textboxes so that I can create a Tab like functionality when Enter key is pressed to move between the input fields. I looked at some of the tutorials online and they don't seem to work.
I need to drop the keyboard before choosing another TextBox to actually input information. any suggestions?
You can force the SIP to close when the user touches 'Enter' with some code in the KeyUp event.
XAML
<TextBox Height='72'
Name='textBox5'
Text=''
Width='460'
KeyUp='textBox5_KeyUp' />
Code
private void textBox5_KeyUp(object sender, KeyEventArgs e)
{
// to force the SIP to close on enter key
if (e.Key == Key.Enter)
{
// be sure and set IsTabStop = true on root element
this.Focus();
}
}