React Native Text element doesn't respect last line break - reactjs

I have the following code to display some content with Text:
const ListItem = ({content}) => {
return <Text>{content}</Text>
}
Given content a value with \ns ("Lorem\nthe\nipsum"), the above code still display line breaks nicely. However, if content ends with \n, for example: "This is a sample text\n", Text somehow dismisses the last \n and does not display the corresponding line break. Is that an expected behavior, and is there a way to make Text respect the last \n?
Thank you very much.

It will not dismiss that, I think your problem lies within your styling of the ListItem.
Just try your <Text>{content}</Text> outside of your ListItem and you will see that new line character works at the end of a string.

Related

If a line of text is separated into multiple text leaves in the accessibility tree, is it still accessible well?

Below is a picture of my current accessibility tree. You can see that the 4 text leaves in it are separated, but it still forms only one line of content. Is this still accessible well ("well" meaning screen readers can detect that they form one complete sentence), or should all of the text leaves be combined into one leaf?
If they should be combined, how can you concatenate variables into the text in React, while keeping it as one single leaf? This is my current code: <p>{cloudiness}% ({cloudinessDescription})</p>
How they are read aloud depends on the screen reader being used. VoiceOver reads it as one phrase, but that doesn't mean others will. Having it split up wouldn't be a nice experience, but it doesn't mean it's not accessible.
If you really want to make sure it's read as one phrase but don't like the noise of the template literal inside the JSX (I agree), why not define the string somewhere else until you are able to test on multiple screen readers?
const cloudinessSummary = `${cloudiness}% (${cloudinessDescription})`;
return <p>{cloudinessSummary}</p>;

Is there a way to limit number of total lines OR line breaks in React Native's TextInput?

I'm trying to either limit the number user line breaks, or just simply limit the total number of lines a user can enter in React Native. Does anyone have a solution for this without any flickering or cursor jumping back and forth? Any help or hints would be great.
Basically I'd like to get it to work how 'maxLength' works for number of characters.
The following will jump the cursor ahead. I've also tried preventingDefault onKeyPress=='Enter', which still causes the jumping of the cursor.
handleTextChange(text) {
let breaks = text.split(/\r\n|\r|\n/).length
if (breaks > 6) {
return
} else {
this.setState({ text: text })
}
}
Using the numberOfLines prop should be what you're looking for. Works in conjunction with multiline=true.
Though it does say it's for Android only.

Reportbuilder showing the same like WPF

So I'm programming and I want to show my first name and last name but i want my last name on a new line. Of course I use the function \n right after my first name. In WPF it shows it like how it should be shown:
first name
last name
If I now want to show this through a report with SSRS this will not work cause my report will show first name \n last name. Is there anyway that report builder will understand this function and give me the same representation like in WPF?
I don't think it will ever understand "\n". Instead of "\n", use "vbcrlf" - that sticks in a carriage return and drops the text to a new line.
You can just encase the field with your text with the below:
=Replace(Fields!<<fieldname>>.Value, "\n", vbcrlf)
Make sure the text is not set to interpret tags as HTML and you'll be fine.

how do you loop thru a listbox and edit each line item in VB express 2010

I have been learning VB for 4 weeks now and I have hit the limits of my knowledge. I sure could use some help from the more experienced programmers!!
Im trying to loop thru my list box and remove the first 4 chars of each line item.
specifically I would like it to behave like this:
first line of list box is selected and sent to string (minus 1st 4 chars)
first line of list box is removed from list box
modified version of first line of list box is added to list box in same position as original
next line of list box is selected...etc....
repeat until entire list box has been modified
Here is a sample of how I'm trying to do this....it almost works :)
Dim test As String
test = ListBox1.SelectedItem.ToString.Substring(4)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
ListBox1.Items.Add(test)
can someone fill in the blanks for me?
Thanks in advance for your help
First, just to double check, you are looping through right?
Next, we can take a look at this line:
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) ListBox1.Items.Add(test)
If I understand this right, you're removing the item at a specific index, then you're adding the new string, test, back into the list. Looking at this, http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.objectcollection.add.aspx, it seems that add will stick this item at the end of the listbox, but you're removing something at a specified index.
Therefore, you're not actually replacing what you probably think you're replacing. That's my best guess. For example, if you remove the 2nd element in your list, but you when you put test back into the list, it's being added onto the end. So something like [a,b,c,d] becomes [a,c,d,b]
Perhaps changing that to:
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) ListBox1.Items.Insert(ListBox1.SelectedIndex, test)
ListBox items can be accessed and edited in this way..
listBox1.BeginUpdate();
try {
for(int i = listBox1.Items.Count - 1; i >= 0 ; i--) {
// do with listBox1.Items[i]
}
} finally {
listBox1.EndUpdate();
}

how to (programmatically) scroll to a specific line in gtktextview/gtksourceview

I am creating a text editor as a way of getting more familiar with C and gtk+. I am using gtk+-2.0 & gtksourceview-2.0, and gtk_scrolled_window . As a first attempt at creating a goto function browser I thought I would just simply create an array of functions found in the document and a corresponding array of lines on which they occur. I have that much done. I was surprised to find that there is no goto line capability that I can easily find in devhelp. It sounds like gtk_text_view_scroll_to_mark () is what I want (after creating a mark), but all the *scroll_to functions require a within_margin, which to be honest I don't really understand.:
From devhelp:
The effective screen for purposes of this function is reduced by a margin of size within_margin.
What does that mean?
Am I even close? How can I create this scroll to line number functionality?
Thanks.
UPDATE: The following three functions were used to scroll to a line in the buffer:
gtk_text_iter_set_line (&start, lineNums[9]);
gtk_text_buffer_add_mark (tbuffer, scroll2mark, &start);
gtk_text_view_scroll_to_mark (text_view, scroll2mark, 0.0, TRUE, 0.0, 0.17);
The last parameter of gtk_text_view_scroll_to_mark was used to get the target line number to line up with the very top line in the buffer. I imagine this parameter will not work on all screen sizes, but I have not tested it.
The gtk_text_view_scroll_mark_onscreen function got me close to the line number, but it was just a couple of lines off the bottom of the text area.
The within_margin parameter controls the area of the screen in which the scrolled-to text should appear or more precisely it sets the amount of space at the border of the screen in which the text should not appear.
This exists so that when you set use_align to false (i.e. you don't want the text to appear at a specific position on the screen), you can still make sure that the text doesn't appear directly at the top of bottom of the screen (which might be bad for readability purposes).
If you don't care at all about the position at which the text will appear, you can use g_text_view_scroll_mark_on_screen which only takes the text view and a mark and no further arguments. This will always scroll the minimum amount to make the text appear on screen.

Resources