In my QML file, I'm using a Flow type. I want the items put in the Flow to be aligned right, but Flow normally aligns from left to right, as in this picture:
The Flow type provides an option to change layout direction, layoutDirection: Qt.RightToLeft, but in this case the order of the items will be wrong: first line will show 2 1 0, second line: 4 3, third line 6 5.
There doesn't seem to be an option in the Flow type to keep flowing the items LTR but align them right.
I've been first trying to replace the Flow with Column and Row types handling the positioning logic myself but it became ugly.
Now I'm thinking about extending the original Flow object to add an extra option. I'm considering taking the Flow source code and tweak it to make my own ExtendedFlow type.
Is there an easier/cleaner way to achieve this? What would be your suggestions?
I would have wrote this as a comment, if stackoverflow didn't restrict me from commenting on question for not having a reputation of atleast 50 points.
I can see an answer in your question. You said "The Flow type provides an option to change layout direction, layoutDirection: Qt.RightToLeft, but in this case the order of the items will be wrong: first line will show 2 1 0"
(If your program logic allows you to do this way)Why not Change layoutDiretion: Qt.RightToLeft and then change the order of your itemsto 2,1,0 so that they will be shown as 0,1,2.
This is much simpler and quicker than taking the Flow source code and tweak it to make your own ExtendedFlow type.
Related
I have a raw string which is like this:
#[{user-356,nam}] #[{user-356,tran}] ()($($ vhv #[{user-356,five}]
And it should be edited in realtime but also have to be displayed like a normal text which is:
nam tran ()($($ vhv five
which have 3 clickable part in the "#" format.
So I used a custom VisualTransformation to transform the cursor indexes from raw one to the displayed one. It worked just fine when just tapping a single cursor (Which mean TextRange .start and .end is the same). But it crashes when I long click to show a ranged selection. The short crash log is below (indexes are for the raw string above)
java.lang.IllegalArgumentException: offset(41) is out of bounds [0,
24]
at androidx.compose.ui.text.MultiParagraph.requireIndexInRangeInclusiveEnd(MultiParagraph.kt:754)
at androidx.compose.ui.text.MultiParagraph.getCursorRect(MultiParagraph.kt:603)
at androidx.compose.ui.text.TextLayoutResult.getCursorRect(TextLayoutResult.kt:529)
So indexes 41 should be the index of the raw string. But indexes [0,24] should be the transformed one. No idea why it uses the wrong indexes for the wrong string. Debugging with breakpoints shows correct calculations when mapping offset. I don't know where this crash comes from. It feels like there is some mis-functioning with the lifecycle of the variable passed into the TextField
I have created a working project here https://github.com/tranhoainam/jetpack-textfield-crash-test
Forgive me for the messy code, I'm just copy it from every class in my project. Any suggestion would be appreciated. It took me a week to try to debug this problem.
Thank you for your time.
I am using arris-capture which makes use of dygraphs for displaying data. The author has kindly provided example data files and an index.html but it is very basic. I have two questions:
1) When I mouse-over any of the graphs, the popup is not formatted nicely. I cannot post an example image because this is my first post. How can I modify the index.html to display the popup that isn't a run on sentence?
I think it would look nicer like this:
2013/08/12 18:24:01
Downstream 1: value
Downstream 2: value
Downstream 3: value
Downstream 4: value
Downstream 5: value
Downstream 6: value
Downstream 7: value
Downstream 8: value
2) The plots included are pretty basic. I would be very interested to see how some of your dygraph wizards might modify them to be more visually pleasing.
Thank you!
There are plenty of things you can do to format the legend.
Check out the documentation here.
To get the legend onto separate lines, use labelsSeparateLines.
To put the legend somewhere else entirely, use labelsDiv.
To completely change the style of the legend, use labelsDivStyles
Is there a way to ellipsize the text content of an NSTextField, instead of truncate?
So instead of:
The quick brown fox jumped over
It would say:
The quick brown fox jumped ...
I can't find anything in the documentation for this. What am I missing?
UPDATE:
Is there any way to ellipsize AND wordwrap--in other words, have multiple lines and ellipsize the last?
So this is a great question! Even though its exposed in IB, its not a property on the view or any subview. Instead its buried as a property on the cell used by NSTextField. So if you ask that object for its cell, you can then read or set the value: lineBreakMode.
Look in the class description for NSCell for all the options - truncateCenter is one (to get center ellipsis).
EDIT: the following thoughts were prompted by the updated question. Personally, I think trying to get that google code is way overkill and perhaps you can do something less complex by creating a mini-custom textField.
create a customer NSView object and give it a string and font property and some methods related to the actions below, and perhaps even a width property
essentially the idea is to use the Cocoa NSString category that lets you determine the length of string (and probably its height) from a string/font combo (I use this in UIKit, did use equivalents in Cocoa, but its been a while...)
one of your view's methods will be 'calculate'. When you get this, covert the string to an array of words using a single space as the separator (or make it more complex). Then, start computing the length of the drawn string, taking the first work, append a space and the second, etc, until you find you have exceeded he width. This is your first line string.
continue doing this for the number of lines that you want to draw (2? 3?). Calculate the length of the unicode char that does ... - its option semicolon as I recall - and keep that around.
in the last line, keep adding words until you exceed the length, and then back up a word at a time, verifying that the last appended strings string (minus a trailing space) but with the '...' char will fit in the space.
you can make this fancier by adding padding around the border etc.
once the calculation is finished (and you of course cache all the bits of the answer), your view is prepared when it gets 'drawRect:...'. You position at (0, bounds.size.height - 21) and draw the first segment, then move down 21 points and draw the second line, etc.
If I were to code this I would plan on 2-4 hours - its not trivial, perhaps the logic is a bit complex, but its straightforward. Good luck!
Although the correct answer was not accepted in this old question - scroll to the last answer - it includes the code Truncate the last line of multi-line NSTextField
The solution includes the use of ellipses and line wrapping combined.
I am using iText and am very new to it. There have been several situations where I think I could have figured out the problem with my code if I knew what I was doing - I use examples without knowing the workings behind the code, and even as I look at the source I can't figure out what the programmer was thinking.
What does setTextMatrix of contentByteArray in iText do? And how do I figure out the parameter values I need?
For example:
cb.setTextMatrix(1, 0);
The input parameters are x,y coordinates in points, unless CTM scaling was defined.
0,0 would be the bottom left of the template you are referencing.
The position is the 'baseline' of the text, rather than the top or the bottom.
Transcribed from this source:
https://sourceforge.net/p/itext/mailman/message/12855218/
first parameter sets left margin, second parameter sets bottom margin.
In my example I have a table where each row is a user for example. Columns could include their name, address, email address, etc. I now need to add a column for (hypothetical example) their cat's names. While most people will have no cats and some people will have 1- 2 cats there will be the occasional person with 20 cats that create one very long row in the table. This is giving me an issue in presentation and for filtering/searching for cat names. Is there a good solution to displaying this type of data?
Have the first 50 (or whatever) characters of the field displayed as normal then put the rest in a block with its visibility set to hidden through CSS. Include a link / button / icon that will allow the user to toggle the visibility so they can see the entire value.
Several options:
Set a maximum width for the cell and allow the data to wrap
Place the content inside a wrapper tag (such as a div) and set the div with a fixed width/height and style of overflow:hidden to ensure that a particularly long word doesn't force out the width of the cell.
Truncate the output text on the server side
For cases #2 and #3, set the Title attribute of the TD tag to contain the full non-truncated text. This will present itself as a tooltip when hovering over the cell.
I would mention other CSS-based solutions but they're very sparsely supported right now, so not worth mentioning.
You might want to try doing something like what SO does. Namely, once someone reaches a certain point in their Rep, it suffixes the number and appromixates it. Ex. 10k instead of 10,236.
That way the numbers don't get out of hand.