MonoDroid Click Delegate and Swipe Detection - delegates

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

Related

(NSWindowButton) NSWindow.standardWindowButton button not highlighting

When i use the following to create a button
NSWindow.standardWindowButton(NSWindowButton.ZoomButton, forStyleMask: 0)
I get a button that doesn't react to mouse hover events. I can augment this by creating a container view with a NSTrackingArea and manually triggering the highlight method but it produces a clicked state.
Is there a way to somehow force the button into the expected behavior state without the darkened background?
I have been trying to avoid subclassing NSButton, but it seems like i may have to, and I'm just in a state of denial.
I could not get this working for the life of me so my solution was to write my own custom buttons. This works fine for me because my NSWindow is already custom so there wont be a clash of style.
https://gist.github.com/icodeforlove/a334884e59784b4c2567
Another viable solution is to use https://github.com/indragiek/INAppStoreWindow as #xhruso00 mentioned, but it seemed like overkill.

Android: OnClickListener of Button on CardView

I'm a bit of a newbie so I apologize if this is an easy question.
I'm following this tutorial: http://www.truiton.com/2015/03/android-cardview-example/#comment-7174
It shows how to make a few CardViews in a layout with 2 TextViews in each - all programmatically.
I would like to modify it to have a Button instead of the TextViews and to have each Button make a Toast notification upon press. I am currently stuck because I have no context to make the Toast with (because I can only access the buttons in the MyRecyclerViewAdapter class). How may I solve this?
Well the fact that you have access to a button, means you have acces to a context. and to my knowledge, a onclick event on a button means that the button is still alive, and then you could assume that the context for the button is still active. The way to get the context from a view is very simple:
view.getContext();
The reason i mention the assumtion is that, relying on a view's context, could be a bad idea (for example after calling a webservice or something else, where a view could have been destroyed).

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" ;)

Mouse event is not detected on my NStableview + cocoa

I have been trying this for past few days but couldnt figure it out.
I have an application which has a NSOutlineView and a NSTableView. Outlineview takes input a path and displays them in the form of a tree structure its sub contents. So when ever a user clicks on a particular folder in the outine view, the contents of the folder should be displayed in the table view with their attributes in the form of a list.
Now i am able to display in both the views respective contents and the interaction between the outlineview and tableview is done using delegates and notifications.
Now my problem is I want to have mouse events to be detected in both the views so that i can make my app more interactive by enabling single click to select, double click to enable opening the file/folder and control+click to enable a contextual pop up menu. but strangely no mouse events are getting detected.
my design of the app is pretty simple with each of table and outline views having their own view and controller class and interactions between them using notifications. Please can you guys suggest me where i am going wrong?
I know i can get single click and double click to work using setAction and DoubleAction methods of table view but i cannot get control click to work. I want to know whats wrong with my app design as non of my views are detecting mouse events :(
Thanks
You can get whether Control is pressed with:
if([[NSApp currentEvent] modifierFlags] & NSControlKeyMask){
//control was pressed at the time the event was posted
}
Or you might want to subclass the NSTableView/NSOutlineView and override mouseDown: to get the event directly.
Also, if your action and doubleAction aren't working, verify that the target/action are correct with something like:
NSAssert([[theView target] respondsToSelector:[theView doubleAction]], #"target/action is wrong");

Resources