Appcelerator call function everytime window open - appcelerator

I am using navigation window in my app.
I want to reset variable when every time window appear.
I tried
$.win.addEventListener("focus", function(e){
alert("window appear");
});
This is not calling. So i tried following:
$.win.addEventListener("open", function(e){
alert("window appear");
});
But this is only call when first time it open..it is not called when screen open from back clicked.

Focus should work if you minimise the app or show the status bar, blur will also be triggered when the window loses focus.
It sounds like you are never closing the window or you are registering the event listeners inside another function, ensure the event listeners are defined at the top level (not in any other functions).
Console.log doesn't work very well in titanium use Ti.API.info('Alert message');

Related

Kendo UI Toolbar and Grid - strange save behavior when triggered from Toolbar control

I have some pages where I have a kendo ui grid (wired up to full CRUD services), but use a separate Kendo UI Toolbar control (as opposed to the toolbar configuration in the grid itself). I have a number of different buttons/menus on the toolbar, but am seeing a strange behavior when calling saveChanges() on the grid. If a cell is being edited when the save button is clicked, the grid is saved, but the edited value is lost (it reverts back to where it was). The following details what I see in different situations:
When using a save button configured in the grid (command: "save"), any changes in a cell being edited are committed with the save.
When using a plain html button that calls the saveChanges() method of the grid, any changes in a cell being edited are committed with the save.
When using a save button configured in a toolbar control, the changes in a cell being edited are LOST when saveChanges() is called.
The following jsbin shows the behavior of all three:
http://jsbin.com/jazobexatu/2/edit?html,js,output
I have tried calling the save from the toolbar button a number of different ways (even trying to trigger the click event of the external button), but nothing seems to correct the behavior. I also tried calling closeCell() on the grid (to try to force the value back into the data, but that doesn't work either). I haven't been able to debug the javascript enough to figure out what is different. I'm hoping someone with a deeper understanding of these controls can help me out.
For some reason, the mouse down event on the toolbar button doesn't cause a blur on the editor.
You can try it yourself by clicking in the cell to edit it, then click and hold the mouse button down on the "normal" button. The editor closes on mouse down, causing a blur of the editor, and persists the change.
If you do the same thing, click and hold mouse down, on the toolbar button, the editor stays open.
I've been poking through the source, but haven't figured out exactly why this happens. My best guess would be that the mousedown handler on the toolbar prevents the event from bubbling or running its default action and the editor doesn't blur.
Additional detail: On mousedown on the grid header button and the normal button, the focused element changes (which is what causes the editor blur). But on mousedown of the toolbar button, the editor input element still has the focus.
Shifting the focus on mousedown of the toolbar might be a workaround.
Sort of a weird hack, but this works in Chrome (any should in any browser that supports activeElement
click: function (e) {
$(document.activeElement).blur();
$("#grid").data("kendoGrid").saveChanges();
}

Showing an NSSharingServicePicker on MouseUp

I'm adding sharing to my app (targeting Mavericks, 10.9), which I want to work like this:
User clicks Share button
Cursor changes to crosshair
User drags selection of what he'd like to share
NSSharingServicePicker displays, allowing the user to pick the service to share with
I'm accomplishing this using the -mouseDown:, -mouseDragged:, and -mouseUp: events. mouseDown begins the selection, mouseDragged provides feedback as to the area being selected, and then mouseUp completes the drag, showing the picker. Each time, though, I get this written to the console:
2014-06-25 00:13:45.111 App[31401:303] Warning: -[NSSharingServicePicker showRelativeToRect: ofView: preferredEdge:] should not be called on mouseUp
Please configure the sender with -[NSControl sendActionOn:NSLeftMouseDownMask];
I don't understand why that would be a problem, unless you were showing it from a button click on mouse up. Should I ignore the message? I've tried showing it using dispatch_async and dispatch_after to try and get it to run outside the event's invocation, but they didn't work. I suppose I could ignore it, but does that leave the door to deprecation open?
I know this is a year late but,
I had the same problem. After some research, I cam back with this answer. Before I implemented this code, my button would spin for a while, and then return with the same error you had. When I click my share button now, it no longer lags, and does not return any error. Insert this into your app's awakeFromNib method:[yourShareButtonName sendActionOn:NSLeftMouseDownMask];.
This is what your code should look like:
- (void)awakeFromNib {
[yourShareButtonName sendActionOn:NSLeftMouseDownMask];
}
I hope this helps!

Flex Components are not getting refreshed

Hi We are using Flex 4 in our project on UI side. On loading the application dashboard, we get a set of pods. We click on a pod and the pod view opens. This pod view contains datagrid with the first column as a hyperlink. When you click on hyperlink another screen opens which is our module screen.
This module screen has a SUBMIT button on top and a couple of datagrids. Now we load data in the grids using RemoteObject. The parent container for each of the grid is a WindowShade Component.
Now our requirement is that the user can make modifications in one or both of the grids and click SUBMIT. Depending upon which grid the user has modified I want to make the corresponding Window shade as read only. IF the user modifies both the grids, I need to make both the Window Shade components as read only and disable the SUBMIT button. The user should be able to see this change immediately on click of SUBMIT without closing the screen or navigating away from the screen.
When the user opens screen for the first time, we get some statuses from backend and Depending upon these statuses, I make the Window shades as read only and enable/disable the buttons. When I click SUBMIT, I still hit the backend and get the status but no enabling/disabling of buttons or window shade happens.
I have written the logic for enabling/disabling in the updateComplete method of my mxml file for which swf is created.
the updateComplete gets called when user opens screen for the first time.It does not get called when the user clicks SUBMIT. why is it so?
I have tried using Loader and SWFLoader to load my SWF file as below but it is not working either.
var request:URLRequest = new URLRequest("com/citi/risk/credit/maintenance/view/widgets/CRCMaintenanceModule.swf");
var loader:Loader = new Loader();
loader.load(request);
Any help or pointers would be greatly appreciated.
Two things you may want to consider:
1) In short, FlexEvent.UPDATE_COMPLETE is an event that gets dispatched has completed rendering itself (gone through a Flex component life cycle). This could happen once, or many times depending on how often the component changes and it's state needs to be re-rendered.
The frequency/timing of this event will vary based on the object that is dispatching it. For example a container that is being resized will dispatch this numerous time. A label that never changes may only do it once.
Instead, you should consider adding a "creationComplete" (FlexEvent.CREATION_COMPLETE) event listener. "creationComplete" only happens once, you can add the listener to any object that contains the submit button.
2) When you click submit, the object you've added the "updateComplete" listener to probably hasn't changed enough to go through Flex's component life cycle. So no event is dispatched.
The answer to why this doesn't happen actually depends on which object you have added the event listener to.
Have you tried using a "click" handler on the submit button, so you could disable the appropriate elements when the button is clicked? Again, the "click" event will happen only once, unlike "updateComplete" ;)

MonoDroid Click Delegate and Swipe Detection

I have a checkbox with a custom image for the button. I used the click delegate to perform an action whenever the button is clicked:
box.Click += { //do some stuff... }
This is working great.
However, now I have been given the requirement to add swipe detection to this checkbox (Sounds crazy but it does actually make sense for this app).
I added the swipe detection using the standard methods I am used to with normal Android in Java: I subclassed GestureDetector.SimpleOnGestureListener and also implemented View.IOnTouchListener.
I added the swipe detection to the checkbox as follows:
/*
SwipeListener implements View.IOnTouchListener
SwipeDetector is a subclass of GestureDetector.SimpleOnGestureListener
*/
SwipeListener listener = new SwipeListener(new GestureDetector(new SwipeDetector(this)));
box.SetOnTouchListener(listener);
When I do this, the swipe works great. But the click delegate no longer gets activated. I tried moving my code for the click to my SwipeDetector class, and that seemed to work.
But then I noticed that my checkbox was no longer getting its checked/unchecked state and so my custom image for it never changed.
I know this has got to be something simple, but I'm not seeing it... What is the proper way to have a click and a swipe on a view (checkbox) in Android/MonoDroid?
My guess without seeing your code is that you are returning true from OnTouch, meaning you have consumed the event and do not wish any further processing to occur using the event. Try returning false if you want the rest of the event to fire.
http://developer.android.com/reference/android/view/View.OnTouchListener.html

Disable Events on Child

Im using Ext JS 4. I have a button inside a container. I want the container to receive mouseover, mouseout, and click events, but the button is causing the mouseover and mouseout event handlers to be called twice on the container. How can i disable the events on the child button?
I believe you are running to 4.0's new bubbleEvents behavior. Components now propagate some events to their parent containers. This happens in code, independent of DOM event bubbling, up the component hierarchy.
http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.container.Container.html
The best fix is to simply stop the event once you've handled it. That should prevent all bubbling, component or DOM. It is generally a good idea to do this for click events to make sure one and only one thing happens in response to a click, but I'm less certain it's appropriate for mouseover and mouseout.
panel.on('click', function(e) {
e.stopEvent();
// do your stuff
});
another fix you could try (I haven't) is to wipe bubbleEvents on the button.
Another, possibly less robust fix is to turn on event buffering:
el.on('click', this.onClick, this, {buffer: 10});
Buffering collapses duplicate events in a configurable time window into one and it's useful for smoothing out rapid fire or duplicate UI events, but I'm not sure how it plays with bubbling.
{
...
preventDefault: true,
...
}

Resources