My WKInterfaceController isnt static. On every call, there will be a new Game loaded.
If i ForceTouch on this Cotroller there comes my Menu with NewGame, restart and so on.
How can i avoid a reload of my WKInterfaceController, when the User DONT click on a menuitem button?
Try putting your code in awakeWithContext() instead of willActivate()
as when you forceTouch ,your WKInterfaceController will reload and reEnter willActivate()
Related
I have a task that are hiding a dialog but I need to click the button belong to this dialog to
implement some function before go to the next dialog.
But when I hide this dialog, I can't click the button. Is there any way to implement this button without On_Bn_Clicked() event? I mean that when the dialog is called, the button is also activated.
Thank for the helps.
When you click the button a few Windows messages are sent. The important ones are WM_LBUTTONDOWN, WM_LBUTTONUP which tells the button you clicked the left mouse button down and up. Then some time later a WM_COMMAND message is sent to the parent window to handle the button click. At that point your ON_COMMAND() MFC handler is called. MFC abstracts this all away from you for the most part.
You could go and simulate this using the Win32 SendMessage API but if the message pump is blocking your button may not be clicked when you think it will. If you want a quick answer to your question then this is an approach to "get it done". It would look something like this:
SendMessage(button.GetSafeHwnd(), WM_LBUTTONDOWN, MK_LBUTTON, 0);
SendMessage(button.GetSafeHwnd(), WM_LBUTTONUP, MK_LBUTTON, 0);
I think a more sensible approach is to take the code that is in this On_Bn_Clicked() event handler and simply move it to a reusable function. This way you can call the code in On_Bn_Clicked() from anywhere in your program.
Just call On_Bn_Clicked() directly from your code. There is no harm in doing so. (I suppose you don't want to actually click the hidden button with the mouse...)
I am currently implementing squiggly in a flex application to enable spell checking. Due to certain requirements, I can not use SquigglyUI to hook onto my spark RichEditableText. I have successfully used com.adobe.linguistics.utils.TextTokenizer to tokenize and highlight mispelt words.
I would like to be able to let the user rightclick on a mispelled word and show a list of suggestions in the context menu using getSuggestions.
I have tried to attach a listener to my RichEditableText:
richtexteditor.addEventListener("rightClick", showSuggestions);
And this is my event handler:
private function showSuggestions(event:MouseEvent):void{
trace('hi there');
}
The problem is when debugging the application, I never get the trace in my console as the rightclick event is never dispatched. In addition, I need to detect the word the user has right clicked on. How can I go about doing this and how can I detect right clicks?
Cheers
All I had to do was add an event handler to the contextmenu property of the richeditable text:
richtexteditor.contextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, doSomething);
r.addEventListener(MouseEvent.RIGHT_CLICK, listener)
This will listen for the right-click of the mouse (Flex4.5)
I'm using MonoTouch and my application setup looks something like this,
NavController
-TabBarController
-NavController
-View1
This works then I click on a tab and am directed to View1. The problem is that this was performed by the tabBarController and not the navigationController. So I get no Back button. Is there a way to capture a TabItemClicked event and manually use the NavigationController to push the View1 onto the stack? So I can get a back button.
I'm hiding the TabBar once I get to View1, so at the moment, there is no way back from View1.
Hope it may help you
http://21gingerman.wordpress.com/2009/04/06/tutorial-and-sample-code-for-iphone-app-with-tab-bar-and-nav-bar/
Here is the scenario...I have an application that has an "Open" button. When you click the open button, a TitleWindow pops up (via the PopUpManager) a dialog that allows you to select a record. In that window, you can either click "Ok" once you've selected a record, or cancel the dialog which should close the window.
What is the best way to handle this, knowing I need to return the record number to the main application? Right now I have the main application opening up the custom TitleWindow. In the TitleWindow, I have an event that fires when the user clicks "Ok" and a record is selected. That's how the main application listens for the recordId. What I'm wondering is if I can do something like this:
private function RecordSelected():void
{
this.selectedRecord = someControl.selectedIndex;
this.dispatchEvent(new Event("RecordSelected"));
PopUpManager.removePopup(this);
}
Will the instance of the TitleWindow stay active until after the event is handled by the main application, or could it be removed before the main application fully handles the event (thus ending with a null reference exception)?
Alternatively, is it better to close the window in the event handler like so:
private function titleWindow_RecordSelected(event:Event)
{
var openDialog:CustomTitleWindow = CustomTitleWindow(e.currentTarget);
this._selectedRecord = openDialog.selectedRecord;
PopUpManager.removePopup(openDialog);
}
I'm also wondering if sending the selection out in an event is the best way to do this also. Any insight would be appreciated. Thanks in advance.
What is the best way to handle this,
knowing I need to return the record
number to the main application?
Best is always subjective, but I usually handle closing of the window in the window component; and then dispatch an event with appropriate data (In this case Record No) back to the application. It sounds like your 90% there. Just instead of dispatching an event Event, create a custom Event class with your recordID. Then it won't matter if the pop up is still in memory or not when you need to use the record ID.
I have a popup button that launches a canvas containing a form that a user can submit. I'm validating this form and displaying an alert when the validation fails. As soon as the user clicks 'OK' on the alert, the canvas launched from the PopUpButton loses focus and closes automatically (its default behavior). PopUpButton._closeOnActivity is private. Any suggestions are greatly appreciated.
Use PopUpManager and a normal button to pop something up manually instead of using a PopUpButton. You can then open and close it when you want to and avoid the default behavior.
var canvas:Canvas = new Canvas();
PopUpManager.addPopUp(canvas, this);
PopUpManager.centerPopUp(canvas);
PopUpManager.removePopUp(canvas);