How to add Page Control in watch application - watchkit

I have seen several apps that is using page control to navigate among screens in watch application. But I wonder how can we add that control in watch interface. Please help.

Use WKInterfaceController.reloadRootPageControllers for this.
Here is example:
WKInterfaceController.reloadRootPageControllers(withNames: ["first", "second"], contexts: nil, orientation: .horizontal, pageIndex: 0)
Call this method to create or modify your app’s page-based interface:
At launch time. Use this method to customize the set of pages you want displayed, and to set the scrolling orientation.
At runtime. Use this method to change the active set of pages or the orientation, adding or removing pages as needed.
NOTE: It's not recommended to uses both navigation types: pages and modal at the same time.

Related

Dialog not displaying propagated model data

In my UI5 application, I have an i18n.properties file with keys and values:
#XMSG:
qty=Quantity
And I'm using this property value in a dialog box as title
onUpdateDialog: function() {
var that = this;
var dialog = new Dialog({
title: "{i18n>qty}",
// ...,
});
dialog.open();
},
But when I run my application, the dialog box title is not getting displayed:
When I use text values from i18n property file somewhere else it's getting displayed.
ManagedObjects, that are created by the application code imperatively outside of the framework-managed features (Such creating an instance of sap.m.Dialog in a Controller code without using the API loadFragment), have to be added to the model delegation chain manually in order to make use of the propagated models.
In order to do so, add the created instance to the parent's <dependents> aggregation. E.g.:
this.getView().addDependent(myDialog); // myDialog is now aware of the "i18n" model
From API Reference:
Special aggregation dependents is connected to the lifecycle management and databinding, but not rendered automatically and can be used for popups or other dependent controls or elements. This allows the definition of popup controls in declarative views and enables propagation of model and context information to them.
In order to use texts in the controller you need to fetch the text first, like so:
this.getOwnerComponent().getModel("i18n").getResourceBundle().getText("qty")
this will be the dialog inside the dialog, so declare a that before the dialog and change this to that..
var that = this;
that.getOwnerComponent().getModel("i18n").getResourceBundle().getText("qty")
Hope this solves your issue..
At the point of opening the Dialog, it doesn't know the i18n model. You need to provide the model to the dialog by calling dialog.setModel(this.getModel('i18n'), 'i18n') before opening the dialog.

Qt installer framework hide or disable buttons

I want to hide or freeze the back button on a page ( to be more specific, License Agreement Page). I tried editing control.qs with few methods but it doesn't seem to work. Following is one of them
Controller.prototype.LicenseAgreementPageCallback = function()
{
var widget = gui.currentPageWidget();
if (widget != null)
{
widget.BackButton.setVisible(false) ;
}
}
I'm facing a similar problem trying to keep hide the Next button in the Target Directory page under certain conditions.
But your case may be easier:
1) You should use a global boolean variable set to true when you enter the License Agreement page.
2) When you enter the previous page test the value of this global: if true then force a click on the next page (gui.click(buttons.NextButton);).
Yes, it's a dirty workaround ;)
I think you could try what I've proposed here: Qt installer framework: remove radio buttons from uninstaller. Even if it wasn't accepted, that what I used in my installer, so I'm pretty confident it's working!
For the wizard BackButton specifically, it automatically disables itself if there are no pages before the current page a la the Introduction page.
From QtScript this can be accomplished by removing any dynamic pages before the current page with installer.removeWizardPage and disabling all default pages before the current page with installer.setDefaultPageVisible(QInstaller.Introduction, false).

Flex - How to get the parent of a custom grid column filter editor and open a pop up window?

I am trying to figure out how to open a pop up window in my Air application, in a secondary Window, instead of the main application window.
I am using the ReusableFX components, which include a custom DataGrid with filtering and other capabilities. The filtering feature displays a pop up window via PopUpManager when you click on the top of a column in the grid.
PopUpManager.addPopUp(this, FlexGlobals.topLevelApplication as DisplayObject);
The problem is that the pop up window opens in the main application - I am assuming because of the 'topLevelApplication' reference.
So, I need a way to open this window in the current Air "s:Window".
I am assuming I need a way to walk up : this.parent.parent or this.owner.owner - though I have tried that and it did not seem to work (it said null reference).
OR, is there a way to get the current top most window / component (NOT the main application / window)?
Update:
I decided to create a new project for the component, and add in the Air libraries. Now I am able to access the "NativeApplication.nativeApplication.activeWindow" call. That gives me the correct Air window. However, it does not seem to be working:
PopUpManager.addPopUp(this, NativeApplication.nativeApplication.activeWindow as DisplayObject);
My popup does not appear. I am assuming because "activeWindow" is not actually a DisplayObject? (so how do I get the DisplayObject if that's the case?)
Update:
Could it be that I am a victim of this adobe bug? (found here originally)
Well, I came up with some changes that seem to work, though there is probably a much cleaner way to do this - I was just not able to figure a way to get a reference to the current air application window except this way (this is using the ReuableFX custom flex component by the way):
First, in my custom DataGridColumn component, I added a public property
public var pApp:Object;
Next, I modified the DropDownFilterHeaderRenderer (extends HBox , implements IListItemRenderer), showFilterDropDown method and right before it calls dropDown.startEdit(column); , added:
column.pApp = parentApplication;
Finally, I modified DropDownFilterEditor (which extends FilterEditorBase), the method startEdit(column:MDataGridColumn) (the previous PopUpManager was calling FlexGlobals.topLevelApplication, which is not the correct window when opening a s:Window in an Air native application:
var editorInstance:Object = _editor.parent;
var columnInstance:Object = editorInstance.column;
var parAppInstance:Object = columnInstance.pApp;
PopUpManager.addPopUp(this, parAppInstance as DisplayObject);

Open Default page without Addressbar, Menubar & Statusbar in ASP.NET

How can I open my Default.aspx page without Addressbar, Menubar & Statusbar?
Remember it's the user with an already-opened web browser that chooses to visit your website, effectively Default.aspx page, whether or not the browser is launched by you or a program while testing your website. So a bit of client-side/JavaScript "magic" is needed to modify or fake the desired result based on an already existing browser window...
Using JavaScript, you can launch a new window with those features turned off, and close the old window. For example, IE's window.open(..) args are specified here.
It provides an example
varCustomFeatures = 'titlebar=no, status=no,menubar=no,resizable=yes, scrollbars=no,toolbar=no,location=no,directories=no,left=0,top=0,height=';
window.open(windowURL, '_blank' , varCustomFeatures,true);
Details may vary between browser in which case you will likely need to employ browser detection.
You can't.
However, you can create a popup windows without the bars in Javascript using open method, like this:
open("MyPage.aspx", "MyWindow", "toolbar=no,status=no,menubar=no");

Flex and fake Mxml initialisation without actually showing the component, (more insise)

I have a TitleWindow mxml class wich has several components, and listeners.
On its creationComplete and init state i add some listeners which listen for events on its gui.
This TitleWindow is only shown when the user click on a "button", i made TitleWindow a singleton with the following code:
public static function getInstance():MyWindow
{
if ( MyWindow.singleton )
{
return MyWindow.singleton;
}
else{
MyWindow.singleton = new MyWindow();
return MyWindow.singleton;
}
}
I needed a singleton because the user will call this window several times as much as he wants and i only need one.
The problem is the following on some special external events i need to "modify" some listeners (remove listeners and add new ones) on a button from MyWindow, before it was even shown once.
I still have MyWindow.getInstance() in memory when my application starts up.
However adding /removing listeners does not seem to have any effect if he actual rendering of the components did not happen, event when using the following code on app startup.
myWindow= MyWindow.getInstance();
myWindow.initialize();
Not suprisingly if i "show" ('render') the myWindow at least once then the events modifications on the myWindow instance works perfectly.
How can i fake the complete initialisation of this component without showing it on startup ?
Thanks !
Which sort of a container holds your button? If you are using a Multiple View Container you can try setting the creationPolicy to all. Single View Containers create all their children in one go and you shouldn't face this problem.
From Flex 3.0 docs I could retrieve this:
The default creation policy for all containers, except the Application container, is the policy of the parent container. The default policy for the Application container is auto.
This looks like the cause for all your troubles.
Update: I did not mention this earlier, since I thought this was to be expected :) Setting the creationPolicy to all makes your application load more slowly. So, read up on Ordered Creation -- this technique helps you to choose if the controls are displayed all in one go (which is the default behavior, after all of the controls have been created) or step-by-step, as and when they are created.

Resources