I'm new to Blackberry and im currently working on it. I have some fields. I want to listen if the focus is moved off a specific field, say objectChoiceField and then take some actions. Anyone of you know how to do this?
With existing classes, you can add a FocusChangeListener, via setFocusChangeListener(). Your listener can take whatever actions you want.
Alternatively, you can override Field.onUnfocus(), and the code in the override will be called when your field loses focus. You can do this with an anonymous subclass, if you only need this once, or you can create a named subclass, and use it repeatedly.
Related
I am developing custom keyboard extension in iOS, and I'm wondering when the two UITextInputDelegate methods (selectionWillChange: and selectionDidChange:) called? Has someone tried to implement these two methods and made them work?
According to this
selection did change is called when the user takes the current highlighted text and replaces the whole thing or part of it. The selection will change is what it is going to change into before the did change event is fired.
I have a UITextField property inside a UIViewController class. I want to allow to set its text using a special method in view controller only. The goal is to move other view controller's elements according to a size of a text inside the text field.
Text field has editing option disabled so it can be setted in code only.
Way 1:
Subclass a UITextField. Looks too extra because I need to set the elements which doesn't belong to this text field. So I need to use a delegate (and as I understand it will be my own delegate only) etc.
Way 2:
Make text field property private. It is my current solution but I don't like that it is fully private.
Can anybody advice a better solution?
I have a switch view on my UI and I'd like to handle the event when its value is changed. To perform this I've made an IBAction method to handle value changed event. So far so good.
My problem is I can't decide if change was performed by
- code (it may happen in my app)
- user interaction
How can I decide if it was changed by a user interaction or by code?
Is there a specific method that changes the switch value when it's done by code only? If so, maybe you could use that method to set a boolean/flag to check against when you need to decide/handle the event.
In Apple ScrollView / ScrollPages Example they have a simmilar situation:
They have to decide whether an event was self(=code) triggered, or by the user.
They simply set a variable (before programatically calling) to distinguish between this two situations.
I have a custom UITextField used for validating for non empty input, correct emails, passwords bigger than x characters etc.
The UITextField has a delegate to itself, since I do all the validation on the text field object itself. Not sure if this is the problem.
This custom UITextField is created in the .XIB file.
The text field sometimes locks the application when editing the text field itself. It also usually locks up when I press the "Next" button on the keyboard (for going to the next text field that needs to be filled).
Xcode doesn't give back an error (such as a loop-error, which I was assuming it was), the application just locks up. This doesn't happen all the time, but usually, if I stress test it with text, then press "Next", it's likely to lock up.
The app doesn't crash...it doesn't go back to the main screen, but it really just locks up, and stays unresponsive.
Any ideas? Let me know if you need more info to figure this out. I'm at a loss at the moment.
edit: Solved, apparently it's not a good idea to set a UITextField's delegate to itself. What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.
I'll also write the answer here:
Apparently it's not a good idea to set a UITextField's delegate to itself, because it can end up going into a loop.
What I ended up doing is creating a separate class that deals specifically as being the delegate for the UITextField and doing all the logic in that class. That class would also have a property connected to the text field it is a delegate for.
Currently I am using UIKeyinput but it is only sending a single delteBackward event even when I hold down the delete key for a long time.
How can I make it send me multiple event calls when I hold delete down for a long time?
There is no easy way to have the system keyboard do auto-repeat. These leaves you with two options:
Fake it by using an overlay on the keyboard (see the comment by #pho0)
Implement a custom keyboard, install it as the inputView for your view or view controller and implement a custom protocol that supports auto-repeat.
Solution 1 works well if you only need the delete key to auto-repeat, but if you need all the keys to auto-repeat the overlay code becomes as complex as the custom keyboard option. (The overlay needs a rectangle for each key, so why not just replace the underlaying keyboard).
Solution 2 involves a certain amount of "up-front" work... One way you might do this is define a key cap class (like a physical key) and a keyboard layout class.
I have implemented both solutions in projects I have worked on, but I currently use solution 2 since I can create whatever keyboard I like. In the simple case the use need never know that it is not the system keyboard. For power users they can customize the keyboard as they see fit.
For what it is worth, I found it useful to have the keyboard class be dumb; it just communicates that a key has transitioned to being down or has transitioned to being up. An additional class above that decides what action should be taken.
In some ways, I know this is not the answer you were looking for, but I hope it helps,
IDZ
One thing I've seen people do is put a fake button on top of the keyboard button. When someone is holding down on it, have a timer remove the last letter every time it fires.
Hope this helps.