Aug
12

Custom cursors in cfform

11 comments Posted by: Laura

Custom cursorWhen a flash form loads, it shows a preloader. After that, while the data that populates the form gets retrieved, a small icon with an animated clock is shown to indicate that something else is coming. I think it is very important to show progress to the user, and that is why I like the new Flash I/O for uploading files because we can show exactly what’s going on.

But what happens when we are retrieving data with Flash Remoting? We can show a small animation like we do in the MXNA Reader, or we can change the icon of the cursor just like Flash forms do by default. Showing an animation might a little difficult to implement and it may not always fit our application, but there is a very easy way to change the cursor while we retrieve the data.

We have too options, one is to use the default “busy “ cursor:

We set the cursor, for example, when we initiate the call:

mx.managers.CursorManager.setBusyCursor();

and then we set it back to normal when we receive the data:

mx.managers.CursorManager.removeAllCursors();

If we only need to show progress, a clock is a good idea, and given that flash forms already show it, we might as well stick with the default busy cursor for consistency.

There might cases though, where we need a custom cursor. In such case, we need to use our second option, using two key elements:

A hidden cfinput type image:

<cfinput type="Image" name="clock" src="images/clock.png" visible="false" height="0" width="0">

And the function to set cursor call:

mx.managers.CursorManager.setCursor( clock.icon,mx.managers.CursorManager.LOWPRIORITY,-9,-9);

The last two parameters (xOffset and yOffset) will depend on the size of your icon. You can omit them and they will default to 0.

We can use png, jpg, gif, svg or, for an animated cursor, a swf.

A live example
Download the source

Category: CFForm | ColdFusion |

11 Comments so far

Write yours
If the files uploaded are unique. How do you change the text field to the new file name?
Jut
2. Jut wrote on October 25, 2005 at 1:55 PM
Is there a way to change the cursor for buttons in Flash forms to the hand instead of arrow, the way CSS does with style=&quot;cursor: hand;&quot;?

It seems like it should be easy enough in Flash forms, but I haven't found a way yet (I've RTM: Flex documentation, Flash Help, CF documentation on Flash form styles).

Thanks for the great service you guys provide to the CF developer community!
Josh Rodgers
3. Josh Rodgers wrote on April 05, 2006 at 10:21 AM
How can you do show a hand cursor when you hover over a cfform component?

In Flex you can do it like this..
http://www.prismix.com/blog/2005/11/how_do_i_display_a_hand_cursor.cfm

Is there a similiar solution for CFForm?
Laura
Josh,
You would do something like this:
&lt;cfform name=&quot;myform&quot; format=&quot;Flash&quot; onload=&quot;formOnLoad()&quot;&gt;
&lt;cfformitem type=&quot;script&quot;&gt;
   public function formOnLoad(){
      var listener:Object = {};
      listener.mouseOver = function(event):Void {
         event.target.onRelease = null;
         event.target.useHandCursor = true;
      }
      
      mybox.addEventListener('mouseOver',listener);
   }
&lt;/cfformitem&gt;
&lt;cfformgroup type=&quot;hbox&quot; id=&quot;mybox&quot;&gt;
..contents of the box
&lt;/cfformgroup&gt;
&lt;/cfform&gt;
There might be a simpler way, but it works.
Joshua
5. Joshua wrote on April 05, 2006 at 11:09 AM
Dang your quick :)

Thanks I will try that out in a second.
Joshua
6. Joshua wrote on April 05, 2006 at 11:24 AM
Seems to be an issue with that, when I implement it just as you explained. The components such as a button or a grid no longer function correctly. meaning the user cant click on a button or a grid. The hand shows instead of the pointer, but the functionality is gone.
Laura
Joshua,
That is because of this line:
event.target.onRelease = null;

You could do something on click, but it will apply to the whole component as in:
event.target.onRelease=_root.getURL('http://localhost');

if you apply the code to a button instead to a container, you could do:

event.target.onRelease= function(){
//whatever you button was supposed to do or a call to a function as in
_root.myButtonClickFunction();
};
8. david wrote on April 11, 2006 at 8:41 PM
Danicurs 6. Amazing True Color animated cursors for Windows.

http://www.yaodownload.com/desktop-enhancements/cursors/danicurs/
Rey
how can I reload the data on a cfgrid after clicking on a button to add/update or delete. I want to show the data after it has been modified.
Serge
Hello,

Concerning the preloader himself, is it possible to determine an x/y position ?

Regards,
Serge
Hello,

Concerning the preloader himself, is it possible to determine an x/y position ?

Regards,

Leave your comment

Comments now closed. This means that probably, the technique or technology discussed here is outdated and by now, things have moved on.

It also means that we are not giving any kind of support for this.