Is there a way to center a TideSDK window in the screen? - tidesdk

When working with TideSDK windows, you get to control their position within the screen. However, I can't find any way to retrieve the screen's size nor a way to center the window.
Is there a way to accomplish that?

You can access the user's screen size with window.screen.width and window.screen.height. You can use those to center a window:
var app_window = Ti.UI.currentWindow;
app_window.setX((window.screen.width-app_window.getWidth())/2);
app_window.setY((window.screen.height-app_window.getHeight())/2);
Note that the window object here is not an instance of Ti.UI.UserWindow but the usual browser window object.

Related

Make an Independent Popup in Qt Quick

I have an app which is small in terms of width and height, I want a popup to show when a button is clicked. Problem is the popup is larger than the app window and when i open it, it scales down and looks weird
APP
APP WITH POPUP
POPUP CONTENT IN DESIGNER
How can i make the popup independent from the app window, like this:
Or is there a better approach rather than using popup, it would be nice if i were able to move the popup/window around. It still needs to be somehow connected to the main app because it get's data from there
A Popup in QML appears as a layer on top of the parent window, so it cannot be bigger than the parent window. If you want a separate, top level window, you should use a Window or a Dialog instead.
I've gotten it sorted out. I encapsulated the component i wanted to show inside a window and created it using Qt.createComponent()
var playListComponent = Qt.createComponent("CustomPlaylist.qml")
var window = playListComponent.createObject(rootWindow)
window.show()
The root element of CustomPlaylist.qml is a Window

moving scroll on chat window automatically

I'm designing a chat window and I'm using overflow:auto in CSS.
I want it continue with end of line, but scroll does not moving, and it's always move to top of the chat window.
Is there a way to do it automatically?
using javascript it will be possible see the following
document.getElementById("id of your div").scrollTop = document.getElementById("id of your div").scrollHeight;

Window position with respect to screen and width and height of window in Qt

I am Using Qt 4.8
I am trying to bind mouse cursor to the center of my application.
If application is in fullscreen it works with following code
int middleX = QApplication::desktop()->width() >> 1;
int middleY = QApplication::desktop()->height() >> 1;
QPoint newMousePos;
newMousePos.setX(middleX);
newMousePos.setY(middleY);
QCursor::setPos(newMousePos);
and it works.
But how do I do this when application is not fullscreen mode?
I tried few codes from the web but I could not found them working. I understand that I need to get current geometry of window i.e. current window position w.r.t. monitor and width and height of window.
but what are the functions to be used for that?
Thanks in advance
All it takes is this:
QCursor::setPos(geometry().center());
This will put the cursor in the dead center of your application window main widget, agnostic of the size and position of the window on the screen.

NSWindow resize limit

I'm trying to create a resize limit for my NSWindow. I don't want the window to scale smaller than 732x or 496y pixels. What would be the best way to go about doing this?
In Xcode click the .xib file and then select your window. In the utilities tray click the size inspector and check the box next to Minimum Size Constraints and set the size
In code you would do it like this:
window.contentMinSize = NSMakeSize(320.0, 568.0);

Full screen mode in silverlight

Would it be possible to show an image in full screen mode using silverlight. I'm looking out for some thing like the full screen option of the flash video players.
You can set
Application.Current.Host.Content.IsFullScreen = true;
this has to be done from a mouse button event or a click, you can't force the user into full screen without some interaction on their part.
Then you'll need to scale the image. If it's in an element that scales automatically, like a Grid cell and the Grid resizes automatically (like if it's the root element on the page and the page doesn't have a width or height specified) then you're good, but otherwise you'll need to handle the Application.Current.Host.Content.FullScreenChanged event and either resize or apply a scale transform to the image or its container to make it fill the screen, and do the same when you go back to non full screen mode.
Set System.Windows.Interop.BrowserHost.IsFullScreen = true.

Resources