PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label mouse-cursor. Show all posts
Showing posts with label mouse-cursor. Show all posts

Saturday, October 8, 2022

[FIXED] What are the best cursor (mouse) tracking applications for web sites?

 October 08, 2022     javascript, mouse-cursor, statistics, tracking     No comments   

Issue

What are the best cursor (mouse) tracking Javascript applications for web sites? To be stored in a database...


Solution

I don't know that there is a pre-packaged general solution to this problem one-click away.

I would recommend picking a good Javascript framework (my personal favorite is MooTools, but jQuery is nice too). Both of these libraries provide nicer ways of handling mouse events in a cross-browser compatible manner.

My advice: Keep a queue of mouse events that you constantly push to a server via AJAX calls. The server-side script that answers the AJAX request can push the data into a database of your choosing.

Take a look at this nice MooTools library for handling advanced mouse gestures to get a good feel of how you might accomplish the mouse movement recording: Moousture.

Edit: After a little more Googling I also came across a MooTools Flashlight Effect which does almost exactly what you want. Instead of updating the position of the flashlight based on mouse movement, you would store the coordinates in a queue that gets pushed to a server later.



Answered By - awesomo
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, May 6, 2022

[FIXED] How to change the cursor type

 May 06, 2022     grid, image, java, mouse-cursor     No comments   

Issue

This question is related to the previous post. How to save file and read

alt text http://freeimagehosting.net/image.php?dc73c3bb33.jpg

How can I change the cursor to "Hand" only when the mouse pointed on grid which is not Null (contained images)?

So far the cursor turn to "Hand" all over the grids (null or not null).

public GUI() {
....
  JPanel pDraw = new JPanel();
  ....
  for(Component component: pDraw.getComponents()){
     JLabel lbl = (JLabel)component;

     //add mouse listener to grid box which contained image
     if (lbl.getIcon() != null)
        lbl.addMouseListener(this);
  }

  public void mouseEntered(MouseEvent e) {
     Cursor cursor = Cursor.getDefaultCursor();
     //change cursor appearance to HAND_CURSOR when the mouse pointed on images
     cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); 
     setCursor(cursor);
  }

Solution

This should have the desired effect:

public GUI() {
  // class attributes
  protected Component entered = null;
  protected Border    defaultB    = BorderFactory...;
  protected Border    highlighted = BorderFactory...;

  ....
  JPanel pDraw = new JPanel();
  ....
  for(Component component: pDraw.getComponents()){
     JLabel lbl = (JLabel)component;

     //add mouse listener to grid box which contained image
     if (lbl.getIcon() != null)
        lbl.addMouseListener(this);
  }

  public void mouseEntered(MouseEvent e) {
     if (!(e.getSource() instanceof Component)) return;
     exit();
     enter((Component)e.getSource());
  }

  public void mouseExited(MouseEvent e) {
     exit();
  }

  public void enter(Component c) {
     //change cursor appearance to HAND_CURSOR when the mouse pointed on images
     Cursor cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR); 
     setCursor(cursor);
     c.setBorder(highlighted);
     entered = c;
  }

  public void exit() {
     Cursor cursor = Cursor.getDefaultCursor();
     setCursor(cursor);
     if (entered != null) {
        entered.setBorder(defaultB);
        entered = null;
     }
  }

Edited post for new stuff in comment. BorderFactory javadoc: http://java.sun.com/javase/6/docs/api/javax/swing/BorderFactory.html. Edit 2: fixed small problem.



Answered By - Chris Dennett
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home
View mobile version

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing