Jump to content

How to "detect" scroll bars ?


Recommended Posts

Hi All,

While in browse mode is there a way to detect if the active window (my layout) has visible scroll bars ?

After using the "Adjust Window - size to fit" script step...
I have a layout that is a list of items, depending on the number of records, this is likely to extend beyond the bottom of the layout window.
If that happens FM (or the computer OS) will show a vertical scroll bar - that bar will "eat up" layout space and force a bottom scroll bar because of the 16 px of the scroll bar.
I am wondering if there is a way to check for the presence of that vertical scroll bar to perform another "Adjust window" script step but this time add the scroll bar size to the layout width to get rid of the bottom scroll bar.

Thanks, D

Link to post
Share on other sites
Posted (edited)

Why don't you see how many records can fit into your window. Then it's a simple test of Get ( FoundCount ) > n.

----

Added:
Actually, there is even simpler way: look at the result of Get ( WindowContentWidth ). If there is no vertical scroll bar, it will return the width of your layout. If there is a scroll bar, it will show 15px (on macOS) less. 

This has the advantage of working independently of your monitor size as well as allowing for a layout with sub-summary parts.

 

Edited by comment
Link to post
Share on other sites

Upon re-reading your question: 

If you do Adjust Window [ Resize to Fit ] while you have more records then will fit into the window, then the vertical scroll bar will be placed to the right of your layout width, the Get ( WindowContentWidth ) function will return the width of your layout and there will be no horizontal scroll bar.

What you describe can only happen if you add records to the found set after adjusting the window (when initially there was no need for a vertical scroll bar).

 

Link to post
Share on other sites

I will play around and do more tests.  When I tried the resize to fit, the layouts go to the top of the screen and all the way to the bottom.
Basically trying to fit as many records as possible on the screen.  I am trying to figure out a way to resize to fit but keep the top of the window to where it was before going into the list layout. So if the user position the window where it's convenient for him I want to keep that position until he decides to move the window again for whatever reason.

Link to post
Share on other sites

II have come up with calculated result that almost works for my needs. One hick-up is that when I use the "OnLayoutEnter" as I enter a new layout, it seems that my global variables are not updated right away but rather they have the values of the previous layout I was in.

So when to these Get functions trigger ?   WindowHeight, WindowWidth, ContentHeight, ContentWidth ?

I thought of putting them on an ExitLayout trigger but only works for WindowTop and WindowLeft - that allows me to position the next window wherever the user positioned the one he was in before switching to the new layout.

Link to post
Share on other sites

Hmmm,  must be my logic that is wrong. I am on a PC, when I look at the pixel numbers I see 29px difference between window and content. From what I found searching here and there 12px would be a left/right window border, which leaves me 17px for the scroll bar.
I read that it should be 16 but I seem to get 17 on my machine. I have attached my LayoutEnterScript in case it is all wrong and I just don't see it anymore. I have hard coded the "default" layout size because they are all the same in what I am working on.

Thanks for the help.

OnLayoutEnter_getWindowSizes.pdf

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.