Text running off the screen in QML, Blackberry - blackberry

I have a problem in Blackberry Native. The text id is a QString, and it contains many words, and I am not sure how to code it such that the text does not run off the screen. I tried LabelTextFitMode and it doesn't work. Any ideas?
Label {
text: "Description:"
textStyle.fontWeight: FontWeight.Normal
textStyle.fontSize: FontSize.Small
textStyle.color: Color.DarkRed // Show this text
}
Label {
id: description // Name this as type_label so that the property alias above can set the text property of this item
//textStyle.fontSize: FontSize.Small
textFit {
mode: LabelTextFitMode.FitToBounds
}
}

Just use multiline like this:
Label {
id: description
multiline: true
}

Related

How to build an adaptive layout in Jetpack Compose

So I am trying to Follow this documentation to achieve something similar to this documentation, this is where the CardTitle moves and image; but the Title and Description on this documentation do not seem to be available on Cards now? I can not access that when I try to create a Card. Biggest issue Card does not have Description anymore, maybe this needs to be updated or how can I achieve this. I am trying to something similar to the image shown.
Code from the Documentation.
#Composable
fun Card(
imageUrl: String,
title: String,
description: String
) {
var showMore by remember { mutableStateOf(false) }
BoxWithConstraints {
if (maxWidth < 400.dp) {
Column {
Image(imageUrl)
Title(title)
}
} else {
Row {
Column {
Title(title)
Description(
description = description,
showMore = showMore,
onShowMoreToggled = { newValue ->
showMore = newValue
}
)
}
Image(imageUrl)
}
}
}
}
Biggest issue Card does not have Description anymore, maybe this needs
to be updated or how can I achieve this. I am trying to something
similar to the image shown.
This is not an issue because the sample above is for demonstrating flexible layout based on screen size using BoxWithConstraints. When you build your layouts you don't have follow this exact pattern.
You can do it in many ways including
Column {
Image(imageUrl)
Title(title)
// You can add a description that is one line with ellipsis overflow for instance. Or it's font size can be smaller than title
}
In your example demonstrator preferred to not show when screen size is less than 400.dp.
BoxWithConstraints is suitable for building a selective layouts based on max or min width/height from its Constraints

amCharts 4: display legend tooltip on truncated (with ellipsis) values only

I've enabled the legend on a amCharts v4 chart with the following code but I have issues with ellipsis:
// Add legend
chart.legend = new am4charts.Legend();
chart.legend.fontSize = 11;
// Truncate long labels (more than 160px)
chart.legend.labels.template.maxWidth = 160;
chart.legend.labels.template.truncate = true;
chart.legend.labels.template.fullWords = true;
// Set custom ellipsis as default one is not displayed correctly
chart.legend.labels.template.ellipsis = "...";
// Set tooltip content to name field
chart.legend.itemContainers.template.tooltipText = "{name}";
As you can see I had to set a custom ellipsis property because Firefox v76 displayed €| instead of … on the truncated legend labels. It happens even on the sample on the amChart website but, surprisingly, not if I open the same URL in a private tab... How can I fix that?
Then I would like to display the tooltip on the legend only for truncated labels. Adding an adapter:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return "My modified " + text;
})
of course works, but how can I identify inside the adapter code if the label that I'm processing is truncated and clear the text variable? It doesn't make sense to display tooltips for non-truncated legend items.
Not sure the most ideal way but...
You get the text inside the adaptor callback.
You can add a text.length check like:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
// 'text' here contains the non-truncated string
return text.length > someValyeBasedOnMaxwidth> ? "My modified " + text: "";
})
I found the answer about the tooltip adapter; this works:
chart.legend.itemContainers.template.adapter.add("tooltipText", function(text, target) {
if (!target.dataItem.label.isOversized) {
// Legend label is NOT truncated, disable the tooltip
return "";
}
// Legend label is truncated, display the tooltip
return text;
})
Still I don't know why the ellipsis are not displayed correctly without setting the property...

QML TextField does not show copy menu on iOS

If I use default TextField control, default ios edit menu for copy/paste is displayed
TextField {
}
But I need TextField control without border, so I use TextFieldStyle
TextField {
text: value
style: TextFieldStyle {
background: Rectangle {
border.width: 0
}
}
}
In this case there is no ios edit menu fo copy/paste. Is possible to have default ios edit menu with TextField without border ?
Add: it works on iOS in Qt 5.7.0

dhtmlxEditor with full control buttons

When I added a dhtmlxEditor type, it shows only basic editor control button such as bold, italic, underline and erase.
ex)
{ type:"editor" , name:"notice", label:"Notice", labelWidth:600, inputWidth:600, inputHeight:279, labelLeft:25, labelTop:50, inputLeft:25, inputTop:71 }
How can I use toolbar option with full control buttons provided?
You need to add property
{ ... toolbar: true ... }

Add text to speak before announcing label's text

I have a label in my app that the user should be able to tap on with VoiceOver enabled to have it speak the text of that label. However, I want it to always say something before it reads the label's text. I tried to set the accessibilityLabel via self.displayLabel.accessibilityLabel = "my text here" + self.displayLabel.text! but this results in it always being set to the label's original text value which is always changing in this app.
How can I add text to announce just before the label's content, ensuring it will always speak the label's current text contents?
Override the accessibilityLabel property in the UILabel subclass to return whatever you'd like.
override var accessibilityLabel: String! {
get {
return "my text here" + "," + self.text!
}
set { }
}
You may want to post an announcement each time the text changes to inform VO users the value has changed.

Resources