Search Results

Search found 241 results on 10 pages for 'gesture'.

Page 4/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • Drag Gestures - fractional delta values

    - by Den
    I have an issue with objects moving roughly twice as far as expected when dragging them. I am comparing my application to the standard TouchGestureSample sample from MSDN. For some reason in my application gesture samples have fractional positions and deltas. Both are using same Microsoft.Xna.Framework.Input.Touch.dll, v4.0.30319. I am running both apps using standard Windows Phone Emulator. I am setting my break point immediately after this line of code in a simple Update method: GestureSample gesture = TouchPanel.ReadGesture(); Typical values in my app: Delta = {X:-13.56522 Y:4.166667} Position = {X:184.6956 Y:417.7083} Typical values in sample app: Delta = {X:7 Y:16} Position = {X:497 Y:244} Have anyone seen this issue? Does anyone have any suggestions? Thank you.

    Read the article

  • XNA Drag Gestures - fractional delta values

    - by Den
    I have an issue with objects moving roughly twice as far as expected when dragging them. I am comparing my application to the standard TouchGestureSample sample from MSDN. For some reason in my application gesture samples have fractional positions and deltas. Both are using same Microsoft.Xna.Framework.Input.Touch.dll, v4.0.30319. I am running both apps using standard Windows Phone Emulator. I am setting my break point immediately after this line of code in a simple Update method: GestureSample gesture = TouchPanel.ReadGesture(); Typical values in my app: Delta = {X:-13.56522 Y:4.166667} Position = {X:184.6956 Y:417.7083} Typical values in sample app: Delta = {X:7 Y:16} Position = {X:497 Y:244} Have anyone seen this issue? Does anyone have any suggestions? Thank you.

    Read the article

  • Android HorizontalScrollView scroll by page

    - by Ionic Walrus
    Hi all, I have implemented a slideshow in my Android app using . This works well except that I want to scroll to next image on a scroll gesture (now it just scrolls past few images before decelerating). I have couldn't find a appropriate way to do this, should I be using a FrameLayout instead ? How do I scroll to the next (or previous) image on scroll gesture ? Any help is appreciated, thanks.

    Read the article

  • How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverContr

    - by SG
    Problem In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for undo/redo. How do other apps do this? Background I have an undo button (UIBarButtonSystemItemUndo) in the toolbar of my UIKit (iPad) app. When I press the undo button, it fires it's action which is undo:, and that executes correctly. However, the "standard UE convention" for undo/redo on iPad is that pressing undo executes an undo but pressing and holding the button reveals a popover controller where the user selected either "undo" or "redo" until the controller is dismissed. The normal way to attach a popover controller is with presentPopoverFromBarButtonItem:, and I can configure this easily enough. To get this to show only after press-and-hold we have to set a view to respond to "long press" gesture events as in this snippet: UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressOnUndoGesture:)]; //Broken because there is no customView in a UIBarButtonSystemItemUndo item [self.undoButtonItem.customView addGestureRecognizer:longPressOnUndoGesture]; [longPressOnUndoGesture release]; With this, after a press-and-hold on the view the method handleLongPressOnUndoGesture: will get called, and within this method I will configure and display the popover for undo/redo. So far, so good. The problem with this is that there is no view to attach to. self.undoButtonItem is a UIButtonBarItem, not a view. Possible solutions 1) [The ideal] Attach the gesture recognizer to the button bar item. It is possible to attach a gesture recognizer to a view, but UIButtonBarItem is not a view. It does have a property for .customView, but that property is nil when the buttonbaritem is a standard system type (in this case it is). 2) Use another view. I could use the UIToolbar but that would require some weird hit-testing and be an all around hack, if even possible in the first place. There is no other alternative view to use that I can think of. 3) Use the customView property. Standard types like UIBarButtonSystemItemUndo have no customView (it is nil). Setting the customView will erase the standard contents which it needs to have. This would amount to re-implementing all the look and function of UIBarButtonSystemItemUndo, again if even possible to do. Question How can I attach a gesture recognizer to this "button"? More specifically, how can I implement the standard press-and-hold-to-show-redo-popover in an iPad app? Ideas? Thank you very much, especially if someone actually has this working in their app (I'm thinking of you, omni) and wants to share...

    Read the article

  • Prevent UIGestureRecognizer from firing selector more than once

    - by JK
    I utilize a UILongPressGestureRecognizer in my app. This is a continuous gesture recognizer which means it continuously fires the selector for the target it was initialized with. I would like the selector to be fired only once. I have tried to prevent further selectors being fired by setting the gesture recognizer's enabled property to Note the first time the selector is fired, but this only takes effect after the selector is fired again. How can I ensure the selector is fired only once?

    Read the article

  • WM6.5 embedded Internet Explorer finder scrolling

    - by Aaron
    I'm writing a .NET 3.5 application targetted for Windows Mobile 6.5. My application uses an embedded IE control to display content. The IE application allows the user to finger scroll around the webpage (i.e. touch the screen and drag instead of using the scrollbar). My IE control has a scrollbar and when I emulate the gesture, I highlight text instead of scrolling. Is there a way to add finger gesture support to an embedded IE control? Thanks, Aaron

    Read the article

  • Can I have multiple colors in a single TextBlock in WPF?

    - by Siracuse
    I have a line of text in a textblock that reads: "Detected [gesture] with an accuracy of [accuracy]" In WPF, is it possible for me to be able to change the color of the elements within a textblock? Can I have a textblock be multiple colors? For example, I would like the whole TextBlock to be black except the gesture name, which I would like to be red. Is this possible in WPF?

    Read the article

  • Attach GestureRecogniser to multiple imageviews

    - by AppleDeveloper
    Something strange I encountered today while attaching same gesture recogniser to multiple image views. It gets attached to only the last one, in other words, it can be attached to only one view! I had to create multiple gesture recognisers to meet my requirements. Following is what I have done. Am I doing correct? Is that's the only way to attach recognisers to the multiple imageviews? Please note that I don't want to use UITableView or UIVIew and put all imageviews in it and attach gesture recogniser to only UITableView or UIVIew. I have all image scattered and I have to detect which image is being dragged. Thanks. [imgView1 setUserInteractionEnabled:YES]; [imgView1 setMultipleTouchEnabled:YES]; [imgView2 setUserInteractionEnabled:YES]; [imgView2 setMultipleTouchEnabled:YES]; [imgView3 setUserInteractionEnabled:YES]; [imgView3 setMultipleTouchEnabled:YES]; [imgView4 setUserInteractionEnabled:YES]; [imgView4 setMultipleTouchEnabled:YES]; [imgView5 setUserInteractionEnabled:YES]; [imgView5 setMultipleTouchEnabled:YES]; [imgView6 setUserInteractionEnabled:YES]; [imgView6 setMultipleTouchEnabled:YES]; //Attach gesture recognizer to each imagviews gestureRecognizer1 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer1.delegate = self; gestureRecognizer2 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer2.delegate = self; gestureRecognizer3 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer3.delegate = self; gestureRecognizer4 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer4.delegate = self; gestureRecognizer5 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer5.delegate = self; gestureRecognizer6 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(gestureHandler:)]; gestureRecognizer6.delegate = self; [imgView1 addGestureRecognizer:gestureRecognizer1]; [imgView2 addGestureRecognizer:gestureRecognizer2]; [imgView3 addGestureRecognizer:gestureRecognizer3]; [imgView4 addGestureRecognizer:gestureRecognizer4]; [imgView5 addGestureRecognizer:gestureRecognizer5]; [imgView6 addGestureRecognizer:gestureRecognizer6];

    Read the article

  • Use your iPhone or iPod Touch as a Boxee Remote

    - by DigitalGeekery
    Are you a Boxee user looking for a remote control solution? Well, you might not need to look any further than your pocket. The free Boxee Remote App turns your iPhone or iPod Touch into a a simple and easy-to-use Boxee remote. The Boxee Remote App works over WiFi, so there is no need for to buy or install additional hardware on your PC. Plus, you don’t even need to be within the line of sight for it to work. Using the Boxee Remote App Download the free Boxee Remote App from the App Store and install it on your iPhone or iPod Touch. See download link below. Next, make sure you have Boxee running on your PC. Select the Boxee icon to open the App.   The first time you log in you’ll be greeted by an introduction screen that will explain the two modes. Click Continue. When opened in “Button” mode, you’ll be presented with 4 directional buttons, an “OK” button, and a back arrow button that works like the Esc key does in Boxee. Button mode performs just as a normal remote. Touching the directional buttons moves your on screen selection right, left, up, and down. Tap the OK button to open or select an item. To enter “Gesture” mode, tap the Gesture button along the top of the Screen. Gesture mode works similar to a touch pad or trackball on a laptop. You drag the Boxee icon with your thumb or finger across the screen to move around within Boxee. The icon will turn red while being dragged or touched. Simply tap the icon to select.   The Settings button allows you to manually add or delete a host computer, or adjust the sensitivity of the controls.     If you need to enter text, such as enter logon credentials for an App, the on screen keyboard will pop up. While watching a video you’ll have on-screen Stop and Pause buttons along with a volume slider.   The Boxee Remote App is simple and easy to use. As long as you can connect via WiFi, you can use it to control any instance of Boxee running on any computer on your network. Download the Boxee Remote App Similar Articles Productive Geek Tips Why Wait? Amazing New Add-on Turns Your iPhone into an iPad! [Comic]Getting Started with BoxeeIntegrate Boxee with Media Center in Windows 7Watch Netflix Instant Movies in BoxeeWin a Free iPod Touch in the How-To Geek Facebook Giveaway! TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips DVDFab 6 Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 Out of band Security Update for Internet Explorer 7 Cool Looking Screensavers for Windows SyncToy syncs Files and Folders across Computers on a Network (or partitions on the same drive) If it were only this easy Classic Cinema Online offers 100’s of OnDemand Movies OutSync will Sync Photos of your Friends on Facebook and Outlook

    Read the article

  • Does Firefox on OS X Lion make use of Full Page Zoom for the touchpad? How to customize behavior?

    - by Steven Lu
    I really like the smooth pinch-zoom of Safari using the touchpad, but the two-finger scroll on Firefox is so much better than the scrolling performance in Safari. So I really like to use Firefox, but then I miss out on two-finger-double-tap to zoom to paragraph width, and the smooth pinch gesture zoom. What I'm wondering is if it is possible to write a Firefox Extension to improve the update rate of the full-page zoom in Firefox that is already functioning via the touchpad pinch gesture. I feel like it is specifically programmed to zoom at certain zoom levels: 100%, 120%, 150% (these are guesses of mine) but I think it would be great if I can get some more control there to make it work more like the zoom functionality in Safari. Also the two-finger-double-tap on a paragraph or element to zoom to it would be really awesome as well. https://developer.mozilla.org/en/Full_page_zoom This seems to indicate (if "full page zoom" is what I think it is) that an extension has the ability to zoom to an arbitrary scale factor, but what remains is to find out if it is possible to obtain or hook the touchpad pinch gesture. Update: I have updated the toolkit.zoomManager.zoomValues option in about:config to include more zoom levels: .3,.5,.67,.8,.9,1,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,1.09,1.1,1.2,1.33,1.5,1.7,2,2.4,3 Notice how I inserted a bunch of entries between 1 and 1.1. But it isn't switching between them any faster (why would it?) so it's less usable than before because of waiting for it to respond fast enough. It's clear that re-rendering the page at a different zoom level requires time and in order for the zoom to be dynamic, some kind of screen capture and scale effect must be performed (which is what Safari does). I guess such a thing is probably doable but I don't think I could pull it off. :-/

    Read the article

  • Getting a gestureoverlayview

    - by Codejoy
    I have been using some nice tutorials on drawing graphics on my android. I wanted to also add in the cool gesture demo found here: http://developer.android.com/resources/articles/gestures.html That takes these lines of code: GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures); gestures.addOnGesturePerformedListener(this); This is fine and dandy yet I realize in my demo i'm trying to build using code from "Playing with Graphics in Android". The demos make sense, everything makes sense but I found out by using: setContentView(new Panel(this)); as is required by the Playing With Graphics tutorials, then the findViewById seems to no longer be valid and returns null. At first I was about to post a stupider question as to why this is happening, a quick test of playing with the setContentView made me realize the cause of findViewById returning null, I just do not know how to remedy this issue. Whats the key I am missing here? I realize that the new Panel is doinking some reference up but I am not sure how to make the connection here. The: R.id.gestures is defined right int he main.xml as: (just like the tutorial) <android.gesture.GestureOverlayView android:id="@+id/gestures" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1.0" /> So I did confirm the setContentView(new Panel(this)) is causing the issue. So I know the issue is that I have to figure out how to add the android.gesture.GestureOverlayView to the panel class somehow, I am just not sure how to go about this. After fighting with this I generally know what I need to do just now how to do it. I think I need either the equivalent of creating a panel in that main.xml OR figuring out how to build whats in main.xml for the gestures in code. I am close because I did this: GestureOverlayView gestures = new GestureOverlayView(this); which gets me a non null gestures now, unfortunately since I am not telling it to fill Parent anywhere I don't think its really showing up, so I am trying hard to figure out layout pa rams. Am I even on the right track?

    Read the article

  • Right Drag on Mac

    - by Mafuba
    How do you perform a right-click-drag operation on Mac hardware? I know you can right click, but there does not seem to be a right click drag gesture. In my specific case I am using a MacBook Pro, and I am in a Windows environment. The question is more than just theoretical. I ask because there is functionality that uses this gesture, at least in the Windows world. For example, right now I'm trying to do a copy and rename in the TortoiseSVN repository browser. I think there are things you can do with a right drag in graphical editors like Photoshop as well. In windows you get a context menu when you right drag files. For those familiar with the software, I know I can do it in other ways; I'm not looking for workarounds to specific problems.

    Read the article

  • Disabling default gestures in Scrybe

    - by RoboShop
    Just upgraded my touchpad drivers and it came with a Scrybe program which allows you to basically do some gesture and automatically load up a website or an application etc. Sounds like it could potentially be very useful. The only thing I don't really like about it is it comes preloaded with like all of these default gestures that take you to facebook, amazon, ebay etc. I'm sure they purposely put them there cause they get money for referels etc. but is there a way to turn them off? I would just like my own links in there. I just think that it takes probably about 2-3 seconds for a gesture to be recognized and that might be due largely to the fact that it's gotta compare it against all these default gestures. If I could somehow disable them, I'm sure it would work faster. Alternatively I'd be happy with a recommendation of a program similar to Scrybe but that works faster.

    Read the article

  • Implementing touch-based rotation in cocoa touch

    - by ewoo
    I am wondering what is the best way to implement rotation-based dragging movements in my iPhone application. I have a UIView that I wish to rotate around its centre, when the users finger is touch the view and they move it. Think of it like a dial that needs to be adjusted with the finger. The basic question comes down to: 1) Should I remember the initial angle and transform when touchesBegan is called, and then every time touchesMoved is called apply a new transform to the view based on the current position of the finger, e.g., something like: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self]; //current position of touch if (([touch view] == self) && [Utility getDistance:currentPoint toPoint:self.middle] <= ROTATE_RADIUS //middle is centre of view && [Utility getDistance:currentPoint toPoint:self.middle] >= MOVE_RADIUS) { //will be rotation gesture //remember state of view at beginning of touch CGPoint top = CGPointMake(self.middle.x, 0); self.initialTouch = currentPoint; self.initialAngle = angleBetweenLines(self.middle, top, self.middle, currentPoint); self.initialTransform = self.transform; } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self]; //current position of touch if (([touch view] == self) && [Utility getDistance:currentPoint toPoint:self.middle] <= ROTATE_RADIUS && [Utility getDistance:currentPoint toPoint:self.middle] >= MOVE_RADIUS) { //a rotation gesture //rotate tile float newAngle = angleBetweenLines(self.middle, CGPointMake(self.middle.x, 0), self.middle, currentPoint); //touch angle float angleDif = newAngle - self.initialAngle; //work out dif between angle at beginning of touch and now. CGAffineTransform newTransform = CGAffineTransformRotate(self.initialTransform, angleDif); //create new transform self.transform = newTransform; //apply transform. } OR 2) Should I simply remember the last known position/angle, and rotate the view based on the difference in angle between that and now, e.g.,: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self]; //current position of touch if (([touch view] == self) && [Utility getDistance:currentPoint toPoint:self.middle] <= ROTATE_RADIUS && [Utility getDistance:currentPoint toPoint:self.middle] >= MOVE_RADIUS) { //will be rotation gesture //remember state of view at beginning of touch CGPoint top = CGPointMake(self.middle.x, 0); self.lastTouch = currentPoint; self.lastAngle = angleBetweenLines(self.middle, top, self.middle, currentPoint); } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self]; //current position of touch if (([touch view] == self) && [Utility getDistance:currentPoint toPoint:middle] <= ROTATE_RADIUS && [Utility getDistance:currentPoint toPoint:middle] >= MOVE_RADIUS) { //a rotation gesture //rotate tile float newAngle = angleBetweenLines(self.middle, CGPointMake(self.middle.x, 0), self.middle, currentPoint); //touch angle float angleDif = newAngle - self.lastAngle; //work out dif between angle at beginning of touch and now. CGAffineTransform newTransform = CGAffineTransformRotate(self.transform, angleDif); //create new transform self.transform = newTransform; //apply transform. self.lastTouch = currentPoint; self.lastAngle = newAngle; } The second option makes more sense to me, but it is not giving very pleasing results (jaggy updates and non-smooth rotations). Which way is best (if any), in terms of performance? Cheers!

    Read the article

  • Ambiguation between multitouch geistures tap and free drag in Windows Phone 8 Emulator (Monogame)

    - by Moses Aprico
    I am making a 2d tile based tactic game. I want the map to be slided around (because it's bigger than the screen) with FreeDrag (It's perfectly done, the map can moved around, that's not the problem). And then, I want to display the character's actions, everytime it's tapped. The problem then appeared. Everytime I want to FreeDrag the map, the Tap trigger always fired first before the FreeDrag one. Is there any way to differ the map sliding than the character tapping? Below is my code. while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); switch (gesture.GestureType) { case GestureType.FreeDrag: { //a } break; case GestureType.Tap: { //b } break; } } Every time I first want to free drag (at the first touch), it always goes to "b" first (see commented line above), and then to "a" rather than immediately goes to "a". I've tried flick, but it seems the movement produced by flick is too fast, so freedrag fits the most. Is there any way or workaround to perform FreeDrag (or similar) without firing the Tap trigger? Thanks in advance.

    Read the article

  • UIView vs CCLayer and Making gestures work in Cocos2d

    - by Lewis
    now I've been been searching for an answer to this question for at least 3 days now. I've tried on many cocos2d forums, including the official one and have heard nothing back. I've found a project which uses custom gestures: https://github.com/melle/OneFingerRotationGestureDemo Explanation here: http://blog.mellenthin.de/archives/2012/02/13/an-one-finger-rotation-gesture-recognizer/ Now I want to implement that behaviour onto a sprite in a cocos2d application. I've tried to do this but it fails to work. It uses a view controller which inherits like this: @interface OneFingerRotationGestureViewController : UIViewController <OneFingerRotationGestureRecognizerDelegate> Now my question is how would I implement the OneFingerRotationGesture behaviour onto a CCSprite in cocos2d 2.0? As interfaces in cocos2d look like this: @interface HelloWorldLayer : CCLayer Now I have asked a similar question to this on stack overflow and a user directed me to this link: https://github.com/krzysztofzablocki/CCNode-SFGestureRecognizers Which I believe makes use of gestures (like the first github linked project) but not custom gestures. I lack the obj-c skills to work out and implement the functionality into my game, so I would appreciate it if someone could explain the differences between CCLayer and UIViewController, and help me implement the OneFingerRotation gesture into a cocos2d 2.0 project. Regards, Lewis.

    Read the article

  • Review: Logitech t620 Touch Mouse and Windows 8

    - by Tim Murphy
    It isn’t very often that I worry much about hardware, but since I heard some others talking about “touch” mice for their Windows 8 machines I figured I would try one out and see what the experience was.  The only Windows 8 compatible touch mouse that they had in the store was the Logitech t630 Touch Mouse.  At $69 it isn’t exactly a cheap purchase. So how does it work with Windows 8.  First it works well as a normal mouse with touch scroll capabilities.  Scrolling works both horizontally and vertically.  Then you get into to the Win8 features, all of which are associated with the back 2/3 of the mouse.  If you double-touch-tap (not depressing the internal button) it acts as a Windows home screen button.  The next feature is switching applications.  This is accomplished by dragging a finger from the left edge of the mouse in.  Bringing up the Windows 8 open apps list is the same movement as on the table where you drag in from the left and then move back to the right.  The last gesture available is to bring up the charms.  This is performed by dragging in from the right side of the mouse. There is a certain amount of configurability.  You can switch dominant hand configuration as well as turn on and off gestures as shown in the screenshot below. It is nice that they kept the gestures similar to the table gestures.  Hopefully future updates to the drivers will bring other gestures, but this is definitely a good start.  It would be interesting to also compare this to the Microsoft Touch Mouse and see if there are additional gestures such as app close and for the app bar. del.icio.us Tags: Logitech,Windows 8,Win8,t620,Logitech t620 Touch Mouse,Gesture

    Read the article

  • obj-c classes and sub classes (Cocos2d) conversion

    - by Lewis
    Hi I'm using this version of cocos2d: https://github.com/krzysztofzablocki/CCNode-SFGestureRecognizers Which supports the UIGestureRecognizer within a CCLayer in a cocos2d scene like so: @interface HelloWorldLayer : CCLayer <UIGestureRecognizerDelegate> { } Now I want to make this custom gesture work within the scene, attaching it to a sprite in cocos2d: #import <Foundation/Foundation.h> #import <UIKit/UIGestureRecognizerSubclass.h> @protocol OneFingerRotationGestureRecognizerDelegate <NSObject> @optional - (void) rotation: (CGFloat) angle; - (void) finalAngle: (CGFloat) angle; @end @interface OneFingerRotationGestureRecognizer : UIGestureRecognizer { CGPoint midPoint; CGFloat innerRadius; CGFloat outerRadius; CGFloat cumulatedAngle; id <OneFingerRotationGestureRecognizerDelegate> target; } - (id) initWithMidPoint: (CGPoint) midPoint innerRadius: (CGFloat) innerRadius outerRadius: (CGFloat) outerRadius target: (id) target; - (void)reset; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; @end #include <math.h> #import "OneFingerRotationGestureRecognizer.h" @implementation OneFingerRotationGestureRecognizer // private helper functions CGFloat distanceBetweenPoints(CGPoint point1, CGPoint point2); CGFloat angleBetweenLinesInDegrees(CGPoint beginLineA, CGPoint endLineA, CGPoint beginLineB, CGPoint endLineB); - (id) initWithMidPoint: (CGPoint) _midPoint innerRadius: (CGFloat) _innerRadius outerRadius: (CGFloat) _outerRadius target: (id <OneFingerRotationGestureRecognizerDelegate>) _target { if ((self = [super initWithTarget: _target action: nil])) { midPoint = _midPoint; innerRadius = _innerRadius; outerRadius = _outerRadius; target = _target; } return self; } /** Calculates the distance between point1 and point 2. */ CGFloat distanceBetweenPoints(CGPoint point1, CGPoint point2) { CGFloat dx = point1.x - point2.x; CGFloat dy = point1.y - point2.y; return sqrt(dx*dx + dy*dy); } CGFloat angleBetweenLinesInDegrees(CGPoint beginLineA, CGPoint endLineA, CGPoint beginLineB, CGPoint endLineB) { CGFloat a = endLineA.x - beginLineA.x; CGFloat b = endLineA.y - beginLineA.y; CGFloat c = endLineB.x - beginLineB.x; CGFloat d = endLineB.y - beginLineB.y; CGFloat atanA = atan2(a, b); CGFloat atanB = atan2(c, d); // convert radiants to degrees return (atanA - atanB) * 180 / M_PI; } #pragma mark - UIGestureRecognizer implementation - (void)reset { [super reset]; cumulatedAngle = 0; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; if ([touches count] != 1) { self.state = UIGestureRecognizerStateFailed; return; } } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesMoved:touches withEvent:event]; if (self.state == UIGestureRecognizerStateFailed) return; CGPoint nowPoint = [[touches anyObject] locationInView: self.view]; CGPoint prevPoint = [[touches anyObject] previousLocationInView: self.view]; // make sure the new point is within the area CGFloat distance = distanceBetweenPoints(midPoint, nowPoint); if ( innerRadius <= distance && distance <= outerRadius) { // calculate rotation angle between two points CGFloat angle = angleBetweenLinesInDegrees(midPoint, prevPoint, midPoint, nowPoint); // fix value, if the 12 o'clock position is between prevPoint and nowPoint if (angle > 180) { angle -= 360; } else if (angle < -180) { angle += 360; } // sum up single steps cumulatedAngle += angle; // call delegate if ([target respondsToSelector: @selector(rotation:)]) { [target rotation:angle]; } } else { // finger moved outside the area self.state = UIGestureRecognizerStateFailed; } } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesEnded:touches withEvent:event]; if (self.state == UIGestureRecognizerStatePossible) { self.state = UIGestureRecognizerStateRecognized; if ([target respondsToSelector: @selector(finalAngle:)]) { [target finalAngle:cumulatedAngle]; } } else { self.state = UIGestureRecognizerStateFailed; } cumulatedAngle = 0; } - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesCancelled:touches withEvent:event]; self.state = UIGestureRecognizerStateFailed; cumulatedAngle = 0; } @end Header file for view controller: #import "OneFingerRotationGestureRecognizer.h" @interface OneFingerRotationGestureViewController : UIViewController <OneFingerRotationGestureRecognizerDelegate> @property (nonatomic, strong) IBOutlet UIImageView *image; @property (nonatomic, strong) IBOutlet UITextField *textDisplay; @end then this is in the .m file: gestureRecognizer = [[OneFingerRotationGestureRecognizer alloc] initWithMidPoint: midPoint innerRadius: outRadius / 3 outerRadius: outRadius target: self]; [self.view addGestureRecognizer: gestureRecognizer]; Now my question is, is it possible to add this custom gesture into the cocos2d project found on that github, and if so, what do I need to change in the OneFingerRotationGestureRecognizerDelegate to get it to work within cocos2d. Because at the minute it is setup in a standard iOS project and not a cocos2d project and I do not know enough about UIViews and classing/ sub classing in obj-c to get this to work. Also it seems to inherit from a UIView where cocos2d uses CCLayer. Kind regards, Lewis. I also realise I may have not included enough code from the custom gesture project for readers to interpret it fully, so the full project can be found here: https://github.com/melle/OneFingerRotationGestureDemo

    Read the article

  • Think before you animate

    - by David Paquette
    Animations are becoming more and more common in our applications.  With technologies like WPF, Silverlight and jQuery, animations are becoming easier for developers to use (and abuse).  When used properly, animation can augment the user experience.  When used improperly, animation can degrade the user experience.  Sometimes, the differences can be very subtle. I have recently made use of animations in a few projects and I very quickly realized how easy it is to abuse animation techniques.  Here are a few things I have learned along the way. 1) Don’t animate for the sake of animating We’ve all seen the PowerPoint slides with annoying slide transitions that animate 20 different ways.  It’s distracting and tacky.  The same holds true for your application.  While animations are fun and becoming easy to implement, resist the urge to use the technology just because you think the technology is amazing.   2) Animations should (and do) have meaning I recently built a simple Windows Phone 7 (WP7) application, Steeped (download it here).  The application has 2 pages.  The first page lists a number of tea types.  When the user taps on one of the tea types, the application navigates to the second page with information about that tea type and some options for the user to choose from.       One of the last things I did before submitting Steeped to the marketplace was add a page transition between the 2 pages.  I choose the Slide / Fade Out transition.  When the user selects a tea type, the main page slides to the left and fades out.  At the same time, the details page slides in from the right and fades in.  I tested it and thought it looked great so I submitted the app.  A few days later, I asked a friend to try the app.  He selected a tea type, and I was a little surprised by how he used the app.  When he wanted to navigate back to the main page, instead of pressing the back button on the phone, he tried to use a swiping gesture.  Of course, the swiping gesture did nothing because I had not implemented that feature.  After thinking about it for a while, I realized that the page transition I had chosen implied a particular behaviour.  As a user, if an action I perform causes an item (in this case the page) to move, then my expectation is that I should be able to move it back.  I have since added logic to handle the swipe gesture and I think the app flows much better now. When using animation, it pays to ask yourself:  What story does this animation tell my users?   3) Watch the replay Some animations might seem great initially but can get annoying over time.  When you use an animation in your application, make sure you try using it over and over again to make sure it doesn’t get annoying.  When I add an animation, I try watch it at least 25 times in a row.  After watching the animation repeatedly, I can make a more informed decision whether or not I should keep the animation.  Often, I end up shortening the length of the animations.   4) Don’t get in the users way An animation should never slow the user down.  When implemented properly, an animation can give a perceived bump in performance.  A good example of this is a the page transitions in most of the built in apps on WP7.  Obviously, these page animations don’t make the phone any faster, but they do provide a more responsive user experience.  Why?  Because most of the animations begin as soon as the user has performed some action.  The destination page might not be fully loaded yet, but the system responded immediately to user action, giving the impression that the system is more responsive.  If the user did not see anything happen until after the destination page was fully loaded, the application would feel clumsy and slow.  Also, it is important to make sure the animation does not degrade the performance (or perceived performance) of the application.   Jut a few things to consider when using animations.  As is the case with many technologies, we often learn how to misuse it before we learn how to use it effectively.

    Read the article

  • What's the best way to handle the same shortcut in WPF and WinForms controls?

    - by Anthony Brien
    I have a WPF application with the following KeyBinding on its main window: <KeyBinding Command="Commands:EditCommands.Undo" Gesture="CTRL+Z" /> <KeyBinding Command="Commands:EditCommands.Redo" Gesture="CTRL+Y" /> This makes the command respond to the shortcut fine. However, in all the places where I have embedded WinForms text boxes or rich text boxes, I've lost the ability to use those shortcuts. If I remove the above bindings, the WinForms shortcuts work fine. How can I support these shortcuts in both WinForms and WPF? I'd prefer a generic method since this problem is likely to affect many other commands with the same keybindings.

    Read the article

  • Swipe gestures on Android ListView items

    - by Bartek
    I have a ListView populated by a ResourceCursorAdapter. I use the loaders mechanism to query a ContentProvider for list items. I detect swipe gestures on the list items to perform some actions on them. New items get added by a background service, so the list can change dynamically. Everything works fine, except when I start swiping and a database change occurs (as a result of the background service adding a new row). In such case the gesture is not detected properly. I noticed that ACTION_CANCEL is dispatched to the list item view and also that bindView is executed for all visible items. Inside the bindView method I only set some text - I don't change any listeners there. How can I make gestures work even when new items are being added by the background service? Perhaps there's a way to prevent the motion from being cancelled or I can pause database updates so they don't interrupt the gesture.

    Read the article

  • Android Custom View to Activity communication

    - by Blumer
    I have a custom control/view that observes the direction of a gesture within its bounds. I would like to send a different message back to the Activity hosting the View depending on the direction of the gesture. I'm having a hard time determine what the right way to do this is. I would think I could raise a custom event in the control and then stick a listener on the control in the activity, but I cannot find any information on custom events in Android. Any help would be appreciated. Thanks.

    Read the article

  • How do you scroll one area of a page using Android's web browser?

    - by Pete
    On the iPhone, safari strips out scrollbars on divs that have overflow set to auto or scroll, but still lets the user scroll with the two-finger swipe gesture. Using an HTC Incredible, we see the scrollbars are again missing, but we cannot figure out any gesture that allows the user to scroll. Is there a special directive we need to add to our HTML? This should affect zillions of websites, any time someone is trying to scroll an area of the page rather than the whole page. Does anyone know how to enable scrolling a div using the web browser on Android phones?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >