Wrox Programmer Forums
|
BOOK: Beginning Building Mobile Application Development in the Cloud
This is the forum to discuss the Wrox book Beginning Building Mobile Application Development in the Cloud by Richard Rodger ; ISBN: 978-1-1180-3469-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Building Mobile Application Development in the Cloud section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2011, 08:57 AM
Registered User
 
Join Date: Apr 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 2 Draw and Mac/MAMP

Hello,

I have been working through this book and it has caused me some issues. I was hoping to get a little help. First, I am on a MacBook Pro and for reasons beyond me I spent the last week trying to get nginx to actually install and work correctly. It has been a lot of trouble, but in the end it never worked right so I went with the easier MAMP setup.

So far so good and all the examples were working just fine up until Chapter 2. The Draw-Tracer app works very well, but the initial Draw app does not. The ontouchestart/ontouchmove events never get called so nothing draws. I even tried this in Chrome and used the excellent debug tools in Chrome to set break points and everything. I thought it was perhaps something in my typing, but that was not the case. I downloaded chapter 2 source and tried it there and the same problem. On FireFox 8, Chrome and Safari, the draw app shows nothing and looks like it isn't working. Lo and behold on the phone it works great and I see my drawing.

I don't know if this was because of something in MAMP? If so why does it work on the phone? I don't fully understand what is happening here, but without being able to test in the browsers and only seeing it work on the phone it makes debugging these apps very hard. Even my break points are not hit on the browser, but they get called on the phone.

Any ideas?
 
Old November 22nd, 2011, 10:01 PM
Registered User
 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm just learning this too but I think the desktop browser doesn't support touch events. Not related to MAMP.

Check out this SO post.
 
Old November 22nd, 2011, 10:36 PM
Registered User
 
Join Date: Apr 2011
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quite possibly, but the book seemed to read as though it would be possible to test this in Safari at the least. It sure doesn't seem like it and since the events never get called, what you linked to makes perfect sense.

I would like to know if there is a better way to do this then. Suspect there isn't quite one.
 
Old April 14th, 2013, 12:50 AM
Registered User
 
Join Date: Apr 2013
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default One potential solution

Quote:
Originally Posted by Akira71 View Post
Quite possibly, but the book seemed to read as though it would be possible to test this in Safari at the least. It sure doesn't seem like it and since the events never get called, what you linked to makes perfect sense.

I would like to know if there is a better way to do this then. Suspect there isn't quite one.
As was noted, desktop Safari doesn't generate touch events, so the existing code sample's events never fire.

You're right that the author is vague in some places (and seems to be misleading in others [chapter 4 node installation]) about whether a given example should work on the desktop only, mobile only, sim only, or some combination there of.

Of course, this is meant to be a mobil web app book, so it's understandable that example code is best run in the sim or on a mobile device.

Regardless (and regardless that it's been over a year since you posted your missive.... sorry it took me so long to find this book!), here's one possible solution that hooks mouse events into the existing touch events:

Code:
    // included just to be able to orient oneself
    canvas.ontouchmove = function(event) {
        event.preventDefault();
        var newx = event.touches[0].clientX;
        var newy = event.touches[0].clientY - canvastop;
        line(lastx, lasty, newx, newy);
        lastx = newx;
        lasty = newy;
    }

    // new code here
    var mouseDown = 0;
    canvas.onmousedown = function(event) {
        ++mouseDown;
        event.preventDefault();
        event.touches = [ {} ];
        event.touches[0].clientX = event.clientX;
        event.touches[0].clientY = event.clientY;
        canvas.ontouchstart(event)
    }
    
    canvas.onmouseup = function(event) {
        --mouseDown;
    }
    
    canvas.onmousemove = function(event) {
        if (mouseDown) {
            event.preventDefault();
            event.touches = [ {} ];
            event.touches[0].clientX = event.clientX;
            event.touches[0].clientY = event.clientY;
            canvas.ontouchmove(event)
        }
    }
        
    var clearButton = document.getElementById('clear');
 
Old April 14th, 2013, 12:52 AM
Registered User
 
Join Date: Apr 2013
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default One potential solution

Quote:
Originally Posted by Akira71 View Post
Quite possibly, but the book seemed to read as though it would be possible to test this in Safari at the least. It sure doesn't seem like it and since the events never get called, what you linked to makes perfect sense.

I would like to know if there is a better way to do this then. Suspect there isn't quite one.
As was noted, desktop Safari doesn't generate touch events, so the existing code sample's events never fire.

You're right that the author is vague in some places (and seems to be misleading in others [chapter 4 node installation]) about whether a given example should work on the desktop only, mobile only, sim only, or some combination there of.

Of course, this is meant to be a mobil web app book, so it's understandable that example code is best run in the sim or on a mobile device.

Regardless (and regardless that it's been over a year since you posted your missive.... sorry it took me so long to find this book!), here's one possible solution that hooks mouse events into the existing touch events:

Code:
    // included just to be able to orient oneself
    canvas.ontouchmove = function(event) {
        event.preventDefault();
        var newx = event.touches[0].clientX;
        var newy = event.touches[0].clientY - canvastop;
        line(lastx, lasty, newx, newy);
        lastx = newx;
        lasty = newy;
    }

    // new code here
    var mouseDown = 0;
    canvas.onmousedown = function(event) {
        ++mouseDown;
        event.preventDefault();
        event.touches = [ {} ];
        event.touches[0].clientX = event.clientX;
        event.touches[0].clientY = event.clientY;
        canvas.ontouchstart(event)
    }
    
    canvas.onmouseup = function(event) {
        --mouseDown;
    }
    
    canvas.onmousemove = function(event) {
        if (mouseDown) {
            event.preventDefault();
            event.touches = [ {} ];
            event.touches[0].clientX = event.clientX;
            event.touches[0].clientY = event.clientY;
            canvas.ontouchmove(event)
        }
    }
        
    var clearButton = document.getElementById('clear');





Similar Threads
Thread Thread Starter Forum Replies Last Post
MAMP & WP Email Configuration msheaver BOOK: Professional WordPress 1 January 7th, 2016 08:31 AM
Trouble getting cpuid example in chapter 4 to work on a Mac malexgreen Assembly Language 1 January 10th, 2010 07:05 AM
How To Draw Using Slago VS.NET 2002/2003 0 March 20th, 2006 09:25 AM
chapter 7 image upload on Mac OS X laolaonk BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 February 19th, 2006 10:20 PM
JRun4 for Mac OS + Mac OS X's Java 1.4.1 elbicho J2EE 0 June 27th, 2003 12:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.