Is there any way to get a TextBox in j2me not editable?
Because I want to fill a lot of lines but I don't want the user to edit it.
For Textbox, this can be achieved by setting TextField.UNEDITABLE constraint (TextField is not a typo):
Indicates that editing is currently disallowed. When this flag is set, the implementation must prevent the user from changing the text contents of this object. The implementation should also provide a visual indication that the object's text cannot be edited. The intent of this flag is that this text object has the potential to be edited, and that there are circumstances where the application will clear this flag and allow the user to edit the contents.
The UNEDITABLE modifier can be combined with other input constraints by using the bit-wise OR operator (|).
UNEDITABLE modifier can be set in TextBox constructor, as well as using setConstraints method. If you're interested in more details on that, refer to TextBox API javadocs
Use constraint as TextField.UNEDITABLE
Isn't it a solution to use a TextField in stead?
Related
I am facing an issue with accessibility implementation in iOS. I have a custom accessibility message which I want the reader to read. The reader does read the custom message BUT ALONG WITH THE MESSAGE IT ADDS ONE WORD "BUTTON" AT THE END. here is my code below:
self.privateToggleButton.accessibilityLabel = "Private. Double tap to toggle setting."
Any idea what I am missing?
If your item is in fact a button, iOS will automatically read out that it is a button as a hint to the user. If the item has some kind of button-like interaction it is recommended you keep this.
But if you really need to get rid of it, you can do so by updating the item's AccessibilityTraits and removing UIAccessibilityTrait.Button.
(Note my descriptions of the fields and classes are based on Mono, so the actual Swift/Objective C implementation/naming conventions may be different.)
Using a UIButton will cause VoiceOver to default to saying the word "Button" as the accessibility trait. This is useful to visually impaired users who might not necessarily be able to tell that the object they are looking at is a button that accepts user interaction. I recommend that you do not remove this trait because VoiceOver users are usually familiar with hearing the trait following the accessibility label of the object.
However, if you absolutely want to remove the specification of "Button", you can use the following line of code to remove the accessibility trait.
self.privateToggleButton.accessibilityTrait = UIAccessibilityTraitNone
As per the other answers, the .button trait should not be removed, since the control appears to be a toggle and its trait is required to indicate the intent and behaviour of the control to VoiceOver users. Do also ensure that the current state of the button is conveyed.
If you really need to remove a trait, they can be removed from controls using code like this:
self.privateToggleButton.accessibilityTraits.remove(.button)
Also note that the "Double tap to X" text is a hint string that should be applied to the accessibilityHint property and not accessibilityLabel.
Is there a native UI control for code input text field, for example like Whatsapp:
No. To achieve this, they're almost certainly tapping into the textField:shouldChangeCharactersInRange:replacementString: method for their UITextField, selectively accepting and formatting user input to match the dash-if-empty approach.
Further, I'm sure they've subclassed the field; per your comments there isn't a blue cursor - which isn't standard for a UITextField.
No there isn't. Use a UITextField, fill it with dashes, keep track of how many characters the user has entered, and replace the dashes accordingly as the user types.
There's a 4-digit code input text field called CodeInputView written in Swift.
In the past I've added a UITextField to the view and set its hidden == true. Then I show/hide the keyboard by calling becomeFirstResponder()/resignFirstResponder() on it. I listen for text did change notifications and update a visible label with the value of the hidden text field.
Is it possible to add a text link into a TextView? I want the link to perhaps behave like a button, where I can assign an action to it.
EDIT: When I say assign an action, I mean actually giving it something in the code. I'm wondering if it's possible to dynamically add a "button" into text that I can assign a coded action to.
Live scenario
Think of something like a dictionary app. Maybe the definition of one word uses another word that you might not know the definition of, so being able to click on that word to instantly search it rather than having to type it in would be a nice user friendly feature. It seems rather unlikely, though, I guess.
I would recommend using NIAttributedLabel from Nimbus, an open source iOS library. You can specify text ranges that are links, and you get delegate messages sent when a user taps on it.
Main Nimbus site: http://nimbuskit.info/
NIAttributedLabel docs: http://docs.nimbuskit.info/interface_n_i_attributed_label.html
in the inspector, go to the Text View Attributes tab then make sure "Detect Links" is checked.
Yes you can. Add the URL into the text view, then open up the Attributes Inspector. You will see an option in there to detect links.
I know of a way, but its a LOT of work. First, you have an NSAttributedString that you have the text view display. Second, attribute the range of text you want to be the button. Third, assign a tap gesture recognizer to the text view and in the method called by the recognizer, you'll use core text to determine if the tap happened over the range of text that represents the buttons.
Heres how youll use core text: create a framesetter with the attributed string. Create a frame from the framsetter with the shape of a square that is the frame of the text view, inset by the padding of the text view. The frame will allow you to get the y origins of every line in the text view and and once you know what line the tap happened on, you can use the line to then figure out exactly what character was tapped on that line by giving it an x offset. Once you know character index on the line, you can add it to the beginning of the range of the line and get the index of the character within the whole string. Then you can check if its within the range of the text that is your button. If it is, you can then call a method to simulate a target action type behavior.
Ive explained the process of how to accomplish this and specified what kinds of core text objects youll need, ill let you look up the specific api details:
https://developer.apple.com/library/mac/documentation/Carbon/Reference/CoreText_Framework_Ref/_index.html#//apple_ref/doc/uid/TP40005304
You can also use my objc core text wrapper:
https://github.com/mysterioustrousers/MYSCoreText
What about CoreText? It Can draw many kinds of Text .
How can I change a secure UITextField text (which is simply a bunch of dots) to (*) asterisk characters like in the image below?
You can set it programmatically by
[textField setSecureTextEntry:YES];
or in IB (secured checkbox at the bottom)
You could also try simply implementing your own "secure text field".
Simply create a normal, non-secure text field, and link it's "Editing Changed" action with a method in your view controller.
Then within that method you can take the new characters every time the text is changed, and add them to a private NSString property, and then set the textField's .text property to a string with just asterisks in it (or any other character if you prefer).
Update: as noted by hayesk below, this solution is no longer ideal, as the introduction of third-party keyboards exposes input on any non-secure text fields to the third-party application, risking them collecting that information, and/or adding it to the autocorrect database.
I have an application, where there are many forms which follow visual form inheritance.
Every form has standard delphi components as well as custom components.
Form validating functionality needs to be added. That is, A small red circle or astric image needs to be drawn next to a control, if the control's value is not valid.
This drawing functionality has to be available through out the application on every control.
What is the best way of implementing this functionality? Is there any design pattern that can help?
Thanks & Regards,
Pavan.
JEDI's JVCL has the TJvValidator component that will do just that for you. Here's a link to the TJvValidators container to get you started.
Something I have done in the past in my validate method was to change the control color to $00C4C4FF for any value which fails validation, or clWindow if it passes. (I use a constant clInvalidEdit). On projects where I am also using Raize controls with a flat border, I also adjust the border to clRed. My required fields generally have a color of $00B0FFFF (again a constant clRequiredEdit).
Most often, I'll create a method named ValidateForm which returns a boolean if the form is valid, or false if its not. The validateform checks every field for validity and adjusts colors where needed, and set the active control to the first field which fails.