How do I do a manual line break in an jQuery Mobile button? - jquery-mobile

I want to have a button with multiple lines. I could add white-space:normal but that does not allow manual line breaks. I have tried with <br> and
but they don't work as a jQM button is text only.
Note that I do not want automatic line-breaks, but I want to decide myself where to put them.
Nor do I want to change the height of the button. No, I want to add extra linebreaks.
i.e. I want to be able to have a button with
Text
like
this
instead of
Text like this
Is there a way around this limitation?

Ok, there is a way to do it. Since I use GWT I can do
JQMButton b = new JQMButton("dummy text");
b.getElement().setInnerHTML("this<br>text<br>works");

a couple of ways to do it
reduce the width of your button, the text would lay out itself in lines
do a shift-enter while typing the text or try a '\n' like this Text \n like \n this

Related

UILabel word wrapping brings extra word to next line when there is enough space for it

Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.

Create edittext like stackoverflow tag text box

I want to create a multi lined edit text that can hold buttons but also have the ability to add free form text.
It should behave like the tag text box of stackoverflow that is under the body of the question when you ask a question on stackoverflow.
I thought about one layout that holds buttons (e.g. tags) and an edit text right after said layout. But as I want it to be multi-lined and if there was a line break, I'm not sure how the edit text should behave, since it couldn't be a quadratic box anymore.
Can you point me in the right direction? I've seen a post about making parts of an edittext uneditable. I could do this and put buttons over it, but the buttons might be a little bigger than the underlying text.
Do you know of alternatives?
I hope you get the point, if not I'll draw the control.
You can achieve same by using FlowLayout. Keep on adding text/button view it will automatically wraps contents to next line

Multiline label with different font styles and IBActions

A perfect example of what I am trying to do is the Instagram comments.
Suppose we have a user and a list of text (the comment). I want my UIView to have the username in some font style and clickable along with text next to it and wrapping around to the next line (which is not clickable).
It might be easier to understand if you just look at this:
Notice how the username is clickable and separated from the text, but the text wraps around to the next line. How can I do this?

Add a Text Link to a TextView

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 .

Replace keywords by images in TextField

I have some textfield with text like "Click #button1, then #button2". Have you got any idea how to replace keywords by images ? I must do it in AS2 :/ I know there is htmlText in textField, but useing it I can only use one image, and image can only align left or right site.
Very advanced stuff. I can tell you there is no 'out of the box' solution like using html text fields or something similar. Especially if you want to mimic nearly html behaviour you have to code advanced routines that can : 1. recognize your keywords. You should google for tokenizers and 2. layout textfields according to occuring images and textblocks. Again, thats advanced!

Resources