Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP equivalent of MouseListener?

Options
  • 23-06-2006 10:13am
    #1
    Closed Accounts Posts: 779 ✭✭✭


    Is there a way to have an equivalent of a java MouseListener which will draw on the screen when the user clicks down on the mouse button, follows the mouse movement drawing on the screen and stops when the user releases the mouse button.

    I can write it in java but have no clue if it can be done in php.


Comments

  • Registered Users Posts: 1,996 ✭✭✭lynchie


    Mouselistener is part of the awt / swing toolkit for writing GUI based applications. Php is NOT a gui based language. It does not interact with the user. if you want to do some interaction with a user on a webpage, consider making your application an applet and embedding it into your page.


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    As said, PHP isn't a GUI-based language, it's a scripting language, so it's generally used for non-interactive tasks.

    That said, I've no doubt that some enterprising individual has written a GUI extension for PHP, along with the load of libraries that would require.

    Because PHP is interpreted, a GUI setup would be quite slow and horrible.


  • Closed Accounts Posts: 169 ✭✭akari no ryu


    Use JavaScript and HTML, or Java, or anythign other than a web-development language for GUIs.

    PHP was written, from the ground up, for Web Development, not GUIs.

    You can get PHP compilers but the entire idea seems kinda pointless to me, it's like sticking a sword at the top of a pole when perfectly good spears already exist.


  • Registered Users Posts: 1,393 ✭✭✭Inspector Gadget


    As has been said here, if you're talking about doing this in a web document, forget it as PHP runs only on the server, not the client. Interactive graphics stuff in a web document are tricky (but not impossible) without Java or Flash or similar.

    However, if you want to write an actual application in PHP (can't think of a single good reason why offhand, mind you), you could look at PHP-GTK (http://gtk.php.net/)?

    Gadget


  • Closed Accounts Posts: 13 smythmark


    You can get PHP compilers but the entire idea seems kinda pointless to me, it's like sticking a sword at the top of a pole when perfectly good spears already exist.

    Quote of the month in my book.:D


  • Advertisement
  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    homeOwner wrote:
    Is there a way to have an equivalent of a java MouseListener which will draw on the screen when the user clicks down on the mouse button, follows the mouse movement drawing on the screen and stops when the user releases the mouse button.

    I can write it in java but have no clue if it can be done in php.
    Well you could do it with Ajax i suppose.

    Something like this? From a chapter of AJAX and PHP: Building Responsive Web Applications book.
    http://ajaxphp.packtpub.com/ajax/whiteboard/

    I don't know but you should buy the book if you want to find out more. i've it ordered.
    Its pretty cool and responsive even with dialup which im on


  • Closed Accounts Posts: 22,479 ✭✭✭✭philologos


    hmm Ajax sounds interesting, I assume that tool would allow you to export it as a png or jpeg with the GD library?


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    I amn't quite sure, the way it is more than likely not.
    But you could capture the co ordinates i suppose and use a custom script to build it using GD. I wouldn't have enough experience nor knowledge to perform such a thing like that unfortuntally


  • Closed Accounts Posts: 779 ✭✭✭homeOwner


    Ok I got it working by writing an applet in java and loading that up into a section of the web page....

    now how can i allow two clients to see the same thing on the applet?
    when one user draws in the applet i want another client to see what he is drawing if they have the applet running. Any hints tips appreciated.


  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    Never done java programming myself but I would imagine you could use an external data file to store the image on. When someone loads the applet then it loads the data into it from this 'global' file where everyone will see the contents.


  • Advertisement
Advertisement