Long strings in system Keyboard plist settings - ios

I try add my own characters in keyboard.
I expand key 'z' by code to "Keyboard-en.plist":
"Roman-Accent-z" = {
Keycaps = "z mylongstringtitle ..."; // ... == \U017e \U017a \U017c characters ('z' with apostrophes and dots)
Strings = "z mylongstringvalue ...";
};
But keyboard not shown my string 'mylongstringtitle', only blank space ' ':
I can add only string 4 chars length on normal font and 7 chars on small font on 'button'. But I need add a long string.
Can I add 'mylongstringtitle' inside keycaps's string? May be I need set special parameters for long string? This is possible?

I don't think you will be able to add long string to be displayed in keyboard-en.plist. I believe the limitations of 4/7chars that you discovered are hard-coded in desire to avoid disfigured popup.

This keyboard behavior is not supported by Apple (it's not documented on http://developer.apple.com, or http://devforums.apple.com). Use of this feature in your app, therefore, is undefined behavior, which is considered programmer error.
That said, it's a neat feature. The limits of 4 and 7 characters for keycaps are hardcoded on iOS. I can't find them in any of the keyboard plists. You'd probably have to modify the keyboard binary to do what you want. (On OS X, on the other hand, this limit does not exist.)
A few alternatives exist, which you might know about:
You could modify this custom keyboard project
You could assign a custom inputView to be displayed at the top of the system keyboard

Related

How to use accessibilitySpeechIPANotation?

In Daniel Devesa Derksen-Staats' book 'Developing Accessible iOS Apps', the following example is included to show how IPA (International Phonetic Alphabet) notation can be used to specify the VoiceOver pronunciation:
let ipaAttributedText = NSMutableAttributedString(string: "Paella is a Valencian rice dish")
let ipaRange = ipaAttributedText.string.range(of: "Paella")!
ipaAttributedText.addAttributes([.accessibilitySpeechIPANotation: "paˈeʎa"], range: NSRange(ipaRange, in: ipaAttributedText.string))
ipaLabel.attributedText = ipaAttributedText
// Excerpt From: Daniel Devesa Derksen-Staats. “Developing Accessible iOS Apps.” Apple Books.
The result, at least in iOS 15, is clearly not what was intended. The accessibility label, as it appears in the VoiceOver caption is "ipa, Paellais a Valencian rice dish" - and this is how it is read. The VoiceOver synth's pronunciation is roughly 'paylace', that is, it is completely ignoring the phonetic transcription (I can replace "paˈeʎa" with literally anything, the pronunciation doesn't change). Also any whitespace between the target word and what follows is deleted in the caption and pronunciation. In the console, I can output the value of the ipaAttributedText, everything there looks ok:
Paella{
UIAccessibilitySpeechAttributeIPANotation = "pa\U02c8e\U028ea";
} is a Valencian rice dish{
}
This blog post contains a very similar example, differing only in that it sets the .accessibilityAttributedLabel instead of .attributedText, but it fails in the same way.
Is this broken on iOS 15? or is there something else needed to make this work?

Can't enter space in textfield using forced uppercase textfield-formatter add-on in Vaadin 8

With the TextField Formatter add-on for Vaadin 8, I can do the following to allow only upper-case characters:
Options options = new Options();
options.setBlocks(dataLen);
if (format[1].equalsIgnoreCase("UPPER"))
options.setForceCase(ForceCase.UPPER);
new CustomStringBlockFormatter(options).extend(field);
However, after setting forced uppercase I can't enter space characters any longer. Does anyone how I can allow spaces as well as forced upper case characters?
The TextField Formatter add-on doesn't support arbitrary groupings.The setBlocks in method in Options determines the fixed space-separated groups, so you can specify e.g. options.setBlocks(3,3,2) to allow entering text in the format of XXX XXX XX. If you want to allow only capitals, but spaces allowed in the middle in any position, like so that both HELLO WORLD and HI WORLD are allowed, you can use a CSS trick to set the letters print in all uppercase. Add the following rule in your theme .scss file:
input.upper-textfield {
text-transform:uppercase;
}
and define your TextField without a formatter, like this:
TextField textField = new TextField("only upper");
textField.setStyleName("upper-textfield");
textField.setMaxLength(dataLen);
Now you just need to remember to change the text to uppercase in Java as well when you read it:
String value = textField.getValue();
if (value != null) {
value = value.toUpperCase();
}

Using CompareText() and AdvPopupMenu

I'm using C++Builder 10.3 with a VCL application for Windows. I'm trying to identify a specific item in an AdvPopupMenu by looping through the Items Caption and comparing the Caption to my search text using CompareText(). The Captions have an '&' in the Caption text which I believe is part of the ShortCut feature. This seems to prevent a match when comparing the text.
I have tried setting up the menu items two ways to try and remove the '&'.
//--#1 Menu Setup--
TMenuItem *NewMenuItem;
NewMenuItem = new TMenuItem(MainForm->AdvPopupMenu1);
TShortCut sc2;
sc2 = TextToShortCut("(None)");
NewMenuItem->Caption = "Google";
NewMenuItem->ShortCut = sc2;
//--#2 Menu Setup--
TMenuItem *NewMenuItem;
NewMenuItem = new TMenuItem(MainForm->AdvPopupMenu1);
NewMenuItem->Caption = "Google";
NewMenuItem->ShortCut = NULL;
Below is my loop to search for the AdvPopupMenu item.
UnicodeString SearchFor = "Google";
UnicodeString TestCaption;
for(int i=0; i<MainForm->AdvPopupMenu1->Items->Count; i++){
TestCaption= MainForm->AdvPopupMenu1->Items->Items[i]->Caption;
if(CompareText(SearchFor , TestCaption)==0 ){
//This CompareText always fails
//TestCaption looks like this "&Google" or this "G&oogle"
}
}
How can I setup the AdvPopupMenu Caption to contain no '&' and make the CompareText work?
The &s are important. Without these, keyboard users like myself will find your application more difficult to use.
I think your best solution is to use the StripHotkey function in the Vcl.Menus unit to remove the ampersand character before you pass the caption to CompareText. (In addition, instead of testing if CompareText returns 0, it's better to use the SameText function.)
That is, don't attempt to create the menu items without the ampersand character, and don't try to remove it from the menu items. Only remove the character from the string you pass to the comparison function.
Also notice that the ampersand character is not related to the ShortCut property. The ampersand character makes the next character underlined in the menu item caption, telling the user than he or she can press that key to activate the menu item, but only when the menu is open. On the other hand, the ShortCut property adds a right-aligned text like Ctrl+A or Shift+Ctrl+N or F2 to the menu item, and these shortcuts are available even when the menu isn't open. Hence, these are different features.

How change app language in real time?

I am working on an app which runs in 2 languages, English and Persian (farsi). So user can select his desired language and app is displayed in that language. What should I do?
Depends on what are your trying to achieve, there is an approach that might be useful to your case, which is:
Declare a global variable which should represents the key of the current used language in the app, call it appLanguageKey String -for example-:
var appLanguageKey = "english"
Create a datastore for storing both languages desired caption for each term, it might looks like (contains):
term_key term_english term_farsi
greeting_key Hello Hoi
bye_key Bye Doei
For now, you could get the desired value if you tried to do:
desiredTerm = "select term_\(appLanguageKey) where term_key = 'greeting_key'"
Consider it as pseudo-code, the condition should be similar to it.
By implementing such a function that returns a string (I will assume that it is: getDesiredCaption(_ termKey: String) -> String in the following code snippet), you will be able to automatically set the desired caption for any UI component, just call it in viewWillAppear method the view controller:
override func viewWillAppear(_ animated: Bool) {
.
.
.
label.text = getDesiredCaption("greeting_key")
// Since that 'appLanguageKey' global viriable is "english",
// the output should be "Hello"
.
.
.
}
All you have to do for changing the language of the app is to change the value of appLanguageKey to "farsi".
For another approach which related to the Internationalization and Localization, you might want to check this answer, it should affect the app to let its navigation to be from right to left.
Hope this helped.
First you should use realm, magical records or an API to store what the user picks. Then you could create your own type of localizeable string handeler, by having an array with 2 dictionaries 1 with english and 1 with persian that all the texts in your application will read from just as you do with a normal localizeable.

Showing unicode in the console in the right format

NSSet *subFolders = [_account subscribedFolders];
NSLog(#"subFolders: %#",subFolders);
Output:
...
"[Gmail]/\U05d8\U05d9\U05d5\U05d8\U05d5\U05ea",
"[Gmail]/\U05d7\U05e9\U05d5\U05d1"
...
Is there any way I can show the above text in its original language (Hebrew) ?
Things I tried:
changing the debugger from LLDB to GDB - Didn't work
Checking under preferences -> Text Editing UTF-* is selected
Thanks
There is no issue with displaying unicode characters in the console, so I would assume it's the way the string is getting into the set in the first place.
I would suggest iterating over all the objects inside subFolders with something like:
for( id object in [subFolders allObjects] ) {
//Print out the name of the item explicitly
}
Even if this doesn't work, it at least lets you work with the strings directly. If it's still printing out:
"[Gmail]/\U05d8\U05d9\U05d5\U05d8\U05d5\U05ea"
It would look as if you're being sent escaped unicode characters, and I would suggest this: https://stackoverflow.com/a/7861345/352891 - this may work directly on NSSet's description
NSString* strOld=[NSString stringWithFormat:#"%#",responseObject];
NSLog(#"%#",[NSString
stringWithCString:[strOld cStringUsingEncoding:NSUTF8StringEncoding]
encoding:NSNonLossyASCIIStringEncoding]);

Resources