I have problem with LWUIT scroll.
I have a form contain textarea and 20 labels. When it scroll to the bottom, it jump to the top (like cycle). Sorry for my bad english :(
This is my code
public class ScrollMidlet extends MIDlet {
public void startApp() {
Display.init(this);
Form mainForm = new Form("Scroll issue");
mainForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
TextArea textArea = new TextArea("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum");
mainForm.addComponent(textArea);
for (int i = 0; i < 20; i++) {
mainForm.addComponent(new Label("This is label " + (i + 1)));
}
mainForm.setScrollable(true);
mainForm.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
You need to disable cyclic focus using the setCyclicFocus method.
mainForm.setCyclicFocus(false);
EDIT: LWUIT scrolling works based on the focus of the current component. So when you press the down arrow, the focus changes to the element below and, if necessary, the Form scrolls. Labels are not focusable by default, so they won't receive focus and the scrolling will not work correctly. To correct this you should modify the label creation.
Label l = new Label("This is label " + (i + 1));
l.setFocusable(true);
mainForm.addComponent(l);
Also, it is really bad user experience to scroll horizontally to read content, so you should forbid horizontal scrolling.
mainForm.setScrollableX(false);
mainForm.setScrollableY(true);
Now setCyclicFocus should work without problems.
Related
When added a long text inside a text view, it works as expected (not truncated).
Xcode 11.0 beta 6 (11M392q)
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.lineLimit(nil)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
But when embedded inside a ScrollView, it gets truncated (not expected):
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView {
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
.lineLimit(nil)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I tried setting a .lineLimit(nil) modifier, but also didn't avoid truncating the text.
Is this the expected behaviour for SwiftUI text? Or is it a bug?
Appreciate if someone can help! : )
Cheers
Text("Your long text goes here")
.fixedSize(horizontal: false, vertical: true)
should solve the problem.
This is default in iOS 13.1 beta 1 and above.
A solution for this problem (seems to be a bug with SwiftUI Xcode Beta 6), is to use the modifier bellow:
.frame(idealHeight: .greatestFiniteMagnitude)
I Have outgoing emails which go like:
Dear XYZ,
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
CASE ID: 123654
Best Regards,
XYZ
The text could be one or two paragraphs. I want to make two regex. One should give me the text in paragraphs and the other should give me the number that is the CASE ID. The result should look like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
123654
I have managed to create a RegEx to get the case using (CASE ID\s*[:]+\s*(\w*)\s*)but I haven't been able to extract the paragraph. Any help will be much appreciated.
Basically you can or should do one regex instead, that will deliver matchgroups.
In almost any other language it would look like this (using "gs" flag to ignore newline):
(.+?)CASE ID: (\d+)
But for vbscript it we have something like this:
(.*?[^\$]*)CASE ID: (\d+)
Also you need to deal with matchgroups like this:
Dim RegEx : Set RegEx = New RegExp
RegEx.Pattern = "(.*?[^\$]*)CASE ID: (\d+)"
RegEx.Global = True
RegEx.MultiLine = True
Dim strTemp : strTemp = "Lorem ipsum " & VbCrLf & "Cannot be translated to english " & VbCrLf & "CASE ID: 153"
WScript.Echo RegEx.Execute(strTemp)(0).SubMatches(0)
WScript.Echo RegEx.Execute(strTemp)(0).SubMatches(1)
The thing is that this will only work if the constant string "CASE ID: " is contained in the message. In case the string is missing e.g. the newline after the ":" it would not work
I need to delete a paragraph enclosed within parentheses like below, without touching the rest of the text as below
(Text to delete Lorem ipsum dolor sit amet, consectetur linebreak->
in voluptate velit esse cillum. Excepteur sint proident, mollit anim id est laborum.)
Text that shouldnt be touched Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation llamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehend in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat upidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
For now I have /\(.*\)[\n]*/ to match a pragraph, but with the linebreaks, it obviously doesn't work. I was thinking about something in the lines of /\(.*[\n]*\)[\n]*/ but that didn't work. Looking here results with (?<=\()(.*?)(?=\)) but its python, so won't work, and other links are about parentheses within parentheses, so that's different from my problem.
The \n is to simplify the (\r|\n|\r\n) linebreak thing.
So is there a way to do it, or is the regexp in groovy not capable of this?
You could use something like /(?s)\(.+?\)/ (example available here), which according to here makes the period character also match new line feeds.
The expression will look for round brackets and stop at the first occurrence of a close bracket.
If I have two components:
nav-menu
nav-button
and nav-menu is a block component that would contain nav-button like so:
{{#nav-menu}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
{{nav-button}}
{{/nav-menu}}
I'd like the button to be able to directly send an action to the menu to tell it to toggle it's visibility state. I guess if I hook into a mutux point in Controller then I could do something like:
{{#nav-menu toggleNavigation=mutex}}
{{nav-button action=mutex}}
{{/nav-menu}}
Is this the only way? Just looking for the most graceful, ember-centric way of doing this.
I've run into this issue before and unfortunately, there's no way in the public API to do this. When creating a block component, anything rendered inside of it has the context of the outer scope, not the component. It's unfortunate that there's no way to change this behavior, but it really does make sense.
I would say that the way you've proposed is the best way to handle this situation: have a variable on the controller that's passed to the outer component. It's inline with Ember's "data down, actions up" philosophy.
I'm trying to split a text of n phrases into paragraphs using regular expressions (i.e. : after a certain number of phrases, begin a new paragraph) with Notepad++.
I have come up with the following regex (in this case, every 3 phrases -> new paragraph) :
(([\S\s]*?)(\.)){3}
So far so good. However, how do I match the phrases now? $1, $2 will only match the braces..
Example text:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
Desired result (using a count of 2):
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat.
Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
How about:
Find what: ((?:[^.]+\.){2})
Replace with: $1\n
Find using this pattern:
((.*?\.){2})
Breaking it down a bit...
The inner parentheses ...
( )
... provide the group which is affected by {2}.
The outer parentheses ...
( )
...provide the delimiters for the replace pattern. Since they are "top-level", they are what the replace pattern \1 will attach to.
Note the outer parentheses have to enclose the {2}. I'm not good at thinking through how regex will handle everything, but fortunately Notepad++ offers instant confirmation -- just press "Find" to watch it jump through the matches.
The replace pattern is followed by your return and new line, so the whole string looks like this:
\1\r\n
If you want an optional space, make sure you add \s? ... probably like this, but I didn't test it.:
((.*?\.\s?){2})
If the issue is inserting a space with the results, just add a space (or two, if you're old-school like me) to the replace pattern:
\1 \r\n
To find n sentence that end with period is quite easy. For instance for two sentence
(?:.*?\.){2}
To make it a paragraph (insert new line) you replace with
$0\r\n\r\n
This insert two carriage return + line feed which is the Windows way of marking new line. On Unix files \n\n would be enough. If you only want one line break, just do $0\r\n\r\n
If you want to make it htlm paragraph same search, you can replace with
<p>$0</p>