I have a coordinate view set up within perspective in percent mode, and I am using multiple instances of a flex view “template” within the coordinate view. This template consists of a few dynamic text boxes, and an LED display. The templates shrink/grow as desired to fit the entire browser window when the coordinate view is resized, but when the view is sized too small or opened from a mobile device the text wraps and expands beyond the extents of its text box (except for the LED display, which scales with the object size). With this being said, my questions are:
1.) Is it possible to detect the wrapping of text within a text box/object?
2.) Is it possible to detect the OS/browser combination of the device launching a perspective session from the session? If so, is there a system.tag or equivalent where this information would be held?
My only solution for this problem so far has been to add a button to the screen to toggle a boolean value that would reduce the text size of each text object that a user could toggle as needed. Any ideas/suggestions on how to accomplish this would be much appreciated.
I’m not sure how this original post went so long without a response, but I’ll try to answer everything all at once…
It’s not possible within Perspective to detect whether a component is wrapping content, although it IS possible to declare/dictate the desired behavior for when content WOULD be wrapped. (Labels, for example have “normal” and “break-word” as wordWrap options, while Flex Containers and Flex Repeaters have their own settings to determine spacing and wrapping).
While there is no exposed property available to determine the browser platform in Perspective, you can determine if a user is using the native mobile application with the following code:
if session.props.device.type in ['ios', 'android']
A common request is for an exposed property which defines the current viewport dimensions of the page. This is something we SHOULD provide, and we have an open ticket to implement the feature. Once these properties are exposed, you could implement whatever logic you’d prefer to determine the size of text, most likely by providing an expression binding on Component.props.style.fontSize which would perform some mathematical calculation and then apply the fontSize value as a percent of original size, instead of a calculated pixel height. (something like 50% for smaller Views).
I haven’t heard any word on it being planned for 8.0.3, so most likely 8.0.4 (August) at the earliest. Features advance further when more users request them, but oddly enough no one has made this request in the ideas forum, so the only visible request is the Feature ticket. posting in the ideas forum would potentially help by increasing visibility of the need for this feature.
I think this feature is absolutely necessary. That is, to be able to scale font based on the screen/container size. Right now it is common for scroll bars to pop up on my templates based on differing screen size. This is because the text can’t scale. Note: I would be fine if the text scaled by “percent” as another solution.
Is there somewhere in the “Inductive Automation Feedback” that I can request this feature as well? I didn’t see anything listed.
How hard would it be to expose the breakpoint the container is currently using with a variable (e.g. for a tab container a variable to indicate whether it is using the small, medium, or large configuration)? I ask because I think I could get the text scaling to work well with a variable like that.
Don't! Not text scaling or any sizing, at least. If you change any element's bounding box in response to a change to the breakpoint, you will cause the breakpoint to re-evaluate. Which can change your element again, which will re-evaluate the breakpoint, ad infinitum. Instead, try using a view property that is bound to a different constant in each break. (And no new feature required.)
Okay, I see your point. I was referring to changing only the text font size (not the bounding box). I believe this is a different scenario as the bounding box should not change based on the font size. Perhaps I am mistaked? The issue is when you have an embedded view (percent based) there is not a way to determine how to change text size
It looks like there is a pretty good solution using media queries. The following is from tech support:
What you can do is create a style with a media query in it. This will allow you to set your font size based on resolution. By default it does it by 300px but of course this is fully configurable and you have the ability to create multiple styles as well. I hope this answers that question. Here is some documentation on media queries and styles https://docs.inductiveautomation.com/display/DOC80/Style+Classes#StyleClasses-MediaQuerySettings
I would not call that a pretty good solution. You would need to create a style for each original font size and screen size combination, with intermediate scaling values for when that screen size is adjusted. For any new original font or screen size, you would need to create a new style, with different font adjustment setpoints.
Not sure if it helps, but we got the media queries (mentioned above) to work pretty well for us. We have a Style for each font size (e.g. Large, Medium, Small, etc.). We made our text with a template. We then placed the template with embedded views and passed the Style as a parameter. If we needed a new size we added a new style to our template. The initial setup was the worst of it but if you are using templates everywhere it cascades pretty quick.