IlliaFM Posted April 9 Posted April 9 Hello everyone. Is there a way to adjust the dimensions of layout parts (body, header, footer, etc.) dynamically from a script? I have a popup dialog layout that I use as a card window, but depending on how much text there is I want to be able to shrink its height. I tried changing the height of the card window, but that doesn't shrink the layout itself and creates scrollbars. Any ideas or workarounds?
Ocean West Posted April 9 Posted April 9 Make the card window to the minimum size you want then based on the content of the message or data you can set dimensions as you draw the window. If the card is in list you can use sub summary parts that become visible if you sort the records by a field associated to the sub summary - just create a blank indexed field. However in list view you will have to mathematically figure out the height you wish the card to show to avoid scrollbars.
comment Posted April 10 Posted April 10 There is no way to shrink a part other than in Preview mode (which will not work for your purpose here). The most you can do is anchor the message to both top and bottom boundaries and then set the window's height accordingly to the size of the message. Unfortunately there is no way to calculate precisely the needed height, so either use some approximation and add a safety margin or use preset sizes. Note that the same problem exists with the native Show Custom Dialog feature: the dialog appears at the same size as last adjusted by the user, and part of the text may be cut off. At least with the card window you have some control over that.
comment Posted April 10 Posted April 10 (edited) 3 hours ago, comment said: there is no way to calculate precisely the needed height Actually, there is a way to measure it - but it takes quite a lot of work... MeasureBeforeDisplay.fmp12 Edited April 10 by comment 3 1
LaRetta Posted April 10 Posted April 10 I simply must say that this is pure genius. Thank you SO MUCH for sharing it with us, Michael!!!
IlliaFM Posted April 11 Author Posted April 11 On 4/10/2024 at 6:00 AM, comment said: Actually, there is a way to measure it - but it takes quite a lot of work... MeasureBeforeDisplay.fmp12 360 kB · 14 downloads I tried this and I see how it's supposed to work. I'm running into a few issues though: 1) I have a footer on my popup layout, and also three input fields that can be hidden or shown based on conditions, but you only used a text box and a button (I doubt it should make a difference but still) 2) I got the card window to resize depending on the content, but the Body part of my popup layout (Alert in your case) still stays the original height, which is 220pt in my case, so it gives me scroll bars. 3) Are you using some setting to make the text box grow to accommodate all the text? The Move/Resize Window makes it clip the text in my case, as if the text field is its default size (I'm using merge field FYI)
comment Posted April 11 Posted April 11 31 minutes ago, IlliaFM said: the Body part of my popup layout (Alert in your case) still stays the original height, which is 220pt in my case, so it gives me scroll bars. When you resize a window that has a header, body and footer parts, only the body part resizes. If you don't want to see scroll bars, make the body part the smallest it can get, so that any resizing will only make it taller than the original. 38 minutes ago, IlliaFM said: and also three input fields that can be hidden or shown based on conditions, I am not sure how that's supposed to fit in with the overall scheme. You could place the fields either above or below the message - but if you hide them. the space they occupy will remain empty. @Ocean West mentioned a possible workaround using a subsumary part that would be shown only when the records are sorted. I believe that could work, but I haven't tested it. 40 minutes ago, IlliaFM said: Are you using some setting to make the text box grow to accommodate all the text? The Move/Resize Window makes it clip the text in my case, as if the text field is its default size (I'm using merge field FYI) The text box grows because it is anchored to both top and bottom boundaries of the body part: https://help.claris.com/en/pro-help/content/auto-resize-options.html You can use a merged field (or even a variable) for the display, but you must use an enterable field for the measuring - and this field must be anchored to the top boundary only. 1
dansmith65 Posted April 11 Posted April 11 @LaRetta shared this sample file with me @comment and I really liked the concept so I played around with it a little. I was able to accomplish the same result with a single layout, which means I'd be more likely to use this technique myself. I also added layout objects so I could measure the various part sizes rather than having to keep a layout size and script config in sync; this is optional and only my preference for maintenance reasons, though. @IlliaFM Since you just mentioned a footer, I added that to my sample file as well. If you try to use my alternate implementation of this technique, be aware there are two fields layered on top of each other that probably only look like one field at a glance. This doesn't solve the other issues @comment just mentioned, though. MeasureBeforeDisplayDS.fmp12 3
IlliaFM Posted April 11 Author Posted April 11 24 minutes ago, comment said: @dansmith65 I appreciate your help, going to check it out. It looks like my issue is that I have a text message and input fields below it. The message will always be on the popup, the input fields may or may not be (1, 2, or all 3 of them). When there is only the message, body still retains the space for input fields, which prevents the message from resizing.
IlliaFM Posted April 12 Author Posted April 12 Go To Field in the MeasureBeforeDisplay solution by @comment makes the field enlarge as shown in screenshots 1 and 2. My field with exact same settings does not enlarge, but rather the text gets smaller (3 and 4). I wonder if that has to do with theme settings.
comment Posted April 12 Posted April 12 17 minutes ago, IlliaFM said: I wonder if that has to do with theme settings. I don't think so. Can you reproduce this behavior in a new file, using the same theme? If so, please post the file (with 1 table, 1 field, 1 layout).
IlliaFM Posted April 12 Author Posted April 12 12 minutes ago, comment said: I don't think so. Can you reproduce this behavior in a new file, using the same theme? If so, please post the file (with 1 table, 1 field, 1 layout). I'm using a custom theme, not sure how to reproduce it in a blank file. But I tried to use different stock themes and the field does resize fine, font size stays the same.
comment Posted April 12 Posted April 12 18 minutes ago, IlliaFM said: I'm using a custom theme, not sure how to reproduce it in a blank file You can import it: https://help.claris.com/en/pro-help/content/importing-themes.html And yes, if your custom theme defines different font sizes for Normal and In Focus states, you will get the behavior you report.
IlliaFM Posted April 15 Author Posted April 15 Okay, I got it to work, the card window changes height and no scroll bars. However...My footer keeps growing as the window grows taller. All the settings are the same as in both example files you guys shared, I can't identify what's affecting it. I have a colored box and some buttons on the footer, they stay put if I don't anchor them to its top. But the footer itself just thickens the more text I add to the message. 9 minutes ago, IlliaFM said: Okay, I got it to work, the card window changes height and no scroll bars. However...My footer keeps growing as the window grows taller. All the settings are the same as in both example files you guys shared, I can't identify what's affecting it. I have a colored box and some buttons on the footer, they stay put if I don't anchor them to its top. But the footer itself just thickens the more text I add to the message. FIXED! It was the lock on the bottom side of the footer objects. I'm sorry for spamming here a bit but thank you to everyone for helping out!
comment Posted April 15 Posted April 15 (edited) 25 minutes ago, IlliaFM said: I'm sorry for spamming here a bit Not at all. You've made an important discovery. I didn't know this until I played with this myself and discovered the same thing, at about the same time you posted your addition: A part that contains objects anchored to its bottom boundary will expand when the window expands. Edited April 15 by comment 1
LaRetta Posted April 15 Posted April 15 3 minutes ago, comment said: A part that contains objects anchored to its bottom boundary will expand when the window expands. I'm not sure I knew it either or I had forgotten or I just did it without much thought ( copying other Devs layout as a theme ) etc. 😀 IlliaFM, that is why we all are here - to share our discoveries.
IlliaFM Posted April 15 Author Posted April 15 I already regretted taking a shot at this feature at one point, it's been bugging me for a few days now. Anyway, appreciate you all 😉
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now