Nativescript - handle emoji in TextField - nativescript

Have a textfield - user enters an emoji (displays correctly) - I save it to a string and then on next visit, populate the TextField with the saved string - get heiroglyphics.
This on both iOS and Android.
How do I need to process strings from TextField which contain emojis.
Thanks

Maybe you want to display it with special font, the most common is font awsome I think. And you can use it like:
https://github.com/NathanWalker/nativescript-fonticon
But instead of font awsome maybe you want something like:
https://emojisymbols.com/emojilist.php
I do not know if it is possible in a TextField thought. But because this if fonts it should theoretically be possible.
then for example =) will be replaced with a

Related

Xamarin : How to set string substring clickable?

I have a problem to show my object field Description on Cross Platform Label . Description has many hashtag, that need to be clicked and open another page. Here is my example :
"I have some #issues that need to be #solved maybe Xamarin#Support can help me."
That is my description, and i want to put it on Label. How can i set those hashtag (#issues, #solved, #Support) to be clickable?
One option is to use a WebView and use simple HTML / CSS. This would give you the most flexibility and in some cases is the simplest.
Another option would be to write custom renderers. There are plenty of answers out there on how to do this natively but as a starting point.
On Android you need to use a TextView with autoLink="web".
On iOS, a UILabel should allow you to do this.
You can change color, ForegroundColor, FontAttributes of the hashtags by using Span in the label. Sadly, Span doesn't have GestureRecognizers.
I suggest you to stack multiple labels and add TapGestureRecognizer on the label with hashtags.

Add flag to OS X menu-bar application

Adding a second input source and selecting Show Input menu in menu bar:
Will result in the display the corresponding flag in the menu bar:
I'm hoping to add a flag to my menu-bar application.
Questions:
Is there a Unicode character for each country's flag?
How would I add an image to the menu bar? What are the dimensions, resolution, and supported image types?
No there is not a Unicode character or emoji for each flag at this time.
You can set the image of the NSStatusItem instance and change it using setImage:
It's a fairly flexible class and you can do other things also for this.
One note, you should take pains to ensure yours is not confused with the input menu. That would be bad for users.

(Mac OS X, Cocoa) How to make drag-and-droppable placeholder elements in an input text field?

I'm writing a Cocoa app where I would like the user to be able to put together a template string using placeholders. (For example, an (artist) placeholder would be filled in by the artist of the song currently playing in iTunes, etc.) I've seen apps that do something like this where each possible placeholder term is displayed in a blue "lozenge," and the user can drag and drop these "lozenges" into an input text field to construct a string, optionally entering some custom text of their own (e.g. separating (artist) and (title) "lozenges" with a hyphen).
Does anyone know if there is any sample code anywhere that will help me implement something like this?
I'm talking about something like this: (this comes from the "Hazel" app where, in a Hazel rule, you can rename a file based on a template pattern you specify)
NSTokenField is focused in the above pic (has the blue ring around it). Each "token" (your lozenges) is an auto-recognized string for the token field. As rdelmar comments above, read up on NSTokenField and you'll be most of the way there.
The "source" of tokens is likely a rounded-edged NSBox containing lined-up borderless, no-background NSTokenFields with one token each. That'll give you easy drag-and-drop as well as easy alignment.
if you need to customize the l&f of the individual tokens, you need to implement your own stuff: NSTextView with NSTextAttachment which have NSTextAttachmentCells... Its painful and a lot of code but actually not that hard
The NSTokenAttachment cell only has lots of private l&f options :(

How to write long formatted text in a Text View with xCode

I feel strange asking a question about what's probably the simplest page in my iPhone app but here it is anyway:
I have a controller that a user can invoke to display the rules of the game and some acknowledgment information. I set up a Text View object filling up the whole page in Interface Builder and am wondering what's the best way of entering the text I need.
I can do all of this in the m file but entering large text sections in a programming language is never fun.
I can also simply overwrite the default "Lorem ipsum dolor..." text in Interface Builder but then my return characters don't seem to be taken into account when I run the app.
Is there a better way to fill my Text View with my own formatted text? And how can I format my text neatly and easily (i.e. make titles in bold, underline some words, etc.)?
Thanks.
There is no way to easily display formatted text in a UITextView. The best approach for this kind of problem is to use a UIWebView and store the text as an HTML file.
Use the NSTextStorage class to store the formatted text in your NSTextView.
Use Core Text
Core Text Tutorial for iOS: Making a Magazine App

Why the text of a disabled NSButton (or NSButtonCell) is gray?

When i set a Button (NSButton) to be disabled, its text color changes to gray.
How can i modify this property? I want the text to stay black.
To answer your Title if not the body of the question: it's practically an industry standard to represent disabled screen elements this way, and probably what users expect.
To do something different might be confusing.
try setTitleColor:forState:, and pass UIControlStateDisabled for the last argument.

Resources