While pasting text to UITextView, textViewDidChange: is not getting called - uitextview

I have a UITextView. I am resizing the text view based on the size of the text inside the method textViewDidChange. This works fine when I type. But this does not get calls when I paste something. Is it expected behavior or am I missing something?

Thats because pasting a text will not call textViewDidChange, but instead will call shouldChangeTextInRange.
What i do is detect if a text is being pasted, then call the methods i use to resize the textView. So in ur shouldChangeTextInRange delegate you will have similar to my answer in:
how to know when text is pasted into UITextView

Related

FabricJS Textbox - The cursor position is not set correctly for certain fonts

In the above image, the cursor should be at the end, but for some reason, it is placed before the last character.
This only happens for certain fonts.
I don't think it is related with how the custom font is being loaded, this image was taken from http://fabricjs.com/loadfonts. Also, the last version of the library is being used.
To reproduce the issue you have to do the following:
Change the font-family to "Pacifico".
Click on the text box to enter in edit mode.
Start typing.
Sometimes, even the last character goes outside of the bounding box.
I think that this has something to do with how the _measureChar() function executes, but I'm not sure what needs to be changed.
Thanks in advance!
Edit:
I did more tests and it seems that this problem is not present in IE.
This problem appears in Chrome and Firefox.
It is also strange how the characters are being rendered in each browser:
add below code before canvas.requestRenderAll();
fabric.charWidthsCache[this.value] = {};
canvas.getActiveObject()._initDimensions();
canvas.getActiveObject().setCoords();

TextArea without Scrollbars

I have a TextArea in my application that actually takes no interactions from the user.
Is there a way to either
Remove the scrollbar entirely and let me handle what happens when the scrollbar would appear?
Use a different object to display text to the screen? I need to be able to append text, but I don't need it to be highlight-able or take any user input.
According to your needs, you need to use label.
If you need TextArea, to remove scrollBars, you can do the next :
Use lookupAll(java.lang.String selector) method to find scrollBars, and
call scrollBar.setOpacity(0.0) for each found scrollBar.
2a. Don't call setVisible(false), as visible property (I believe) is used to TextArea to control scrollBar visibility.

Qt text editor on picture

I haven't found an exact question on this.
I have a picture, it could be blank for the sake of the example, or contain something that I want to add a fancy caption to. I want to add text editing means (akin to Photoshop) on top of the picture.
I'm thinking about subclassing QGraphicsScene and placing a subclassed QTextEdit object on the scene upon pressing a text placement button. Then, when you click on this object, in addition to editing the text, additional text editing tools become available - so you can set parts of text to bold, italic, modify color, size, etc. And then you would be able to change the object's position - and I think that's available in QGraphicsScene by default. And for the background QBrush, there would be a background picture.
Is this a reasonable solution?
Maybe there are any ready-available examples of this, but I haven't found them yet.
My solution
Text item:
For the text item, I used QGraphicsScene with a subclassed QGraphicsTextItem. For the background picture, I used a QGraphicsRectItem with a QBrush and a loaded picture using QImage methods.
To edit parts of the selected text in this subclassed QGraphicsTextItem:
QTextCharFormat applied to my subclassed QGraphicsTextItem using QGraphicsTextItem::textCursor().mergeCharFormat(...). This way I can change formatting, such as boldness, italics, etc. on the selection only.
Some more thingies:
To pan and zoom around the scene, I used an excellent guide by Vpicaver complete with source code from http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming

How to prevent UITextField from displaying multiple lines?

Yes, you read right - my UITextField has multiple lines for some reason and it is driving me crazy.
I have an app where users can edit content directly in a UITableViewCell. When they tap the cell, the text in the cell's label is put into a UITextField that is then added to the UITableViewCell. Once the UITextField hits a certain amount of characters (not sure exactly what the magic number is), it splits onto multiple lines and looks terrible - the first row is clear, but the second row is clipped by the bottom border of the UITextField.
I do not want to use a UITextView as I prefer the single line in my situation. Has anybody seen this behavior before? Is there a way to prevent it?
Oh, I am using iOS 4.1 as my base SDK.
Found it - the clipsToBounds property of the UITextField needs to be set to YES. If using Interface Builder, the "Clip Subviews" box needs to be checked.

Problems with MFC link control wrapping

I'm using a CMFCLinkCtrl in my custom dialog that inherits from CDialog. The CMFCLinkCtrl is set dynamically using data that is set by the user in another part of the application, so I have to handle long urls.
Is there a way to have the link control truncate what is displayed in the dialog and add an ellipse to the end? Currently the control is wrapping to the next line when it is too long to fit in the dialog or sees the "//" in the http://.
Static controls have an SS_ENDELLIPSIS style that does exactly what you want, but unfortunately this won't work with CMFCLinkCtrl which is derived from CButton. So you have two choices:
Use a static control with the SS_ENDELLIPSIS style, but you'll have to set the text colour and font yourself, and handle click events and open the URL manually.
Subclass CMFCLinkCtrl and add custom drawing code to add the ellipsis.
I think you're out of luck. You'll have to do what casablanca said or without subclassing truncate the text yourself (calculate the font size and link control size) and set it using SetWindowText.
You can easily resize the control to contain the entire text using SizeToContent, but I don't think this works for you.

Resources