Titanium - Get height of current window - titanium

Is it possible to get the height of the current window as pixel value?
Or alternatively, the screen height as pixel value?

For window height you can use Ti.Platform.displayCaps.platformHeight
You can also try method
view.getRect().height or view.toImage().height to get the view height.
hope this will help you.

Related

Titanium: How to determine the screen width when using SplitView?

I'm used to using Titanium.Platform.displayCaps.platformWidth all over my app to get the width of the window.
But with SplitView on the iPad Titanium.Platform.displayCaps.platformWidth still returns the total screen size of the iPad (as it probably should).
How can I determine the actual available screen width for the app while using SplitView?
I don't mean SplitWindow BTW. This is in regards to SplitView where you can line up two different apps next to each other on the iPad
Thank you!
you can get the width your uiElement using postLayout event
var uiWidth;
myElement.addEventListener('postlayout', postlayout);
function postlayout(e){
uiWidth = e.source.rect.height;
myElement.removeEventListener('postlayout', postlayout);
}
An easy way to determine how wide a certain view is, is to use toImage() on the UI element, and then get the size.
So... when you do
console.log($.myWindow.toImage().rect.width);
You should get the width of the window. Which should be the width allocated to your app.

NSFullSizeContentViewWindowMask and title/toolbar height?

I am attempting to implement something similar to Safari where the window's style mask is set to NSFullSizeContentViewWindowMask so the NSToolBar and title bar blur the background view.
This works fine, however I have a view that I need to not be clipped by the toolbar/titlebar, similar to how Safari's WebView has an initial top padding that doesn't cover the content when the view is unschooled.
My attempted solution was to create a dummy NSView which the unclipped views align their top value to, then changing the height constant of the dummy view to the height of the titlebar/toolbar. The issue, however, is that there seems to be no way to calculate the height of the toolbar.
This suggests that I calculate the height by subtracting the height of the contentView from the height of the window, but that only works (returns 0 otherwise as the two heights are equal) if I don't use NSFullSizeContentViewWindowMask which I want to use for the blurring effect.
Am I overlooking something simple, or is there no simple way to accomplish this?
Check NSWindow's contentLayoutRect property.

WKInterfaceTable scrollbar height

How can I change the height of a WKInterfaceTable scrollbar? By default scrollbar height is equal to 1 row‘s height. What I am missing?
There is NO such API to achieve this currently. WatchKit is very limited.
It's not the row hight, it's the size of the digital crown.

Frame size property not working

I have a little problem, I am trying to set an image inside a frame to the frame's size.
However, the Width and Height properties return garbage.
What am I doing wrong?
See gw, gh:
Listen for the WindowActivatedEventHandler to get the size using ActualWidth/ActualHeight. This ensures that the Window is activated and the Frame has been drawn before trying to get the height/width.

How to make an NSWindow only resizable vertically?

I have a Window in my NIB which is resizable, but would like to enforce it to only be resizable vertically. How can I go about doing this?
In IB's size section, for both minimum and maximum width give the same value then you will not be able to re size horizontally.