Quality Custom Cursor (Dukes)

I have created my own Custom Cursor that is displayed while a long task is running (in a different thread) to show the user that the program is busy.
Cursor search1 = myToolKit.createCustomCursor(myToolKit.getImage("Resources/Images/Cursor1.png"), new Point(0, 0), "Search1");Sun says:
Note that multi-frame images are invalid and may cause this method to hang.
So I created a Timer that changes the icons every 500ms to give the impression of a slow animated cursor.
This works, however,
There are three problems:
1. The time between changing frames is not 500ms, it seems to be very jumpy. It is running in a different thread so I thought it wouldn't be a problem. Is there any way to regulate this?
2. The size of the cursor seems fixed, can I change it? (The size of the Image I use for the CustomCursor does not seem to make a difference)
3. The quality appears really bad. I am using a png file that looks really clear at 100% size in Photoshop. Should I use a particular format?
Thanks for any help
Charlie

Thanks very much for the quick reply.
I have done a bit of testing on your suggestions..
1. You could try upping the priority of that thread.Seems to work (sort of), think I'm just going to leave it!
2. Depends on your OS. See Toolkit.getBestCursorSize.Whatever size I give it, the bestCursorSize comes out as 32x32. Do you know if any other sizes are supported or if I can override it e.g. 64x64? Using XP (Can I change the settings in the OS?)
Would it just be best to resize my image files then?
3. See Toolkit.getBestCursorSize API doc.Thanks!
Think I'll give you the Dollars unless someone else comes up with a great answer soon
Charlie

Similar Messages

  • Custom cursor using image gets resized bigger

    I have created a custom cursor using the following code:
    ClassLoader cl = this.getClass().getClassLoader();     
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    Cursor Custom_Cursor = tk.createCustomCursor(im,new Point(9,9),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The cursor is loaded and it works, however - the image I use for the cursor is resized so it gets too big. Any clues on why this happens?
    btw; draftGrid is one of my own classes that extends JComponent.
    - bjorn

    Thanks for your replies guys.
    I tried your code KPSeal, and it works in resizing the cursor image back to its original size. However, a gray square of size 32,32 (which is returned by getBestCursorSize()) is shown round the cursor.
    Here is the updated code (yours hade some minor bugs)
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    try {
           tracker.addImage(im, 0 );
           tracker.waitForID(0);
    } catch( InterruptedException ie ) {
           ie.printStackTrace();
    int w = im.getWidth(this);
    int h = im.getHeight(this);
    int pw = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).width;
    int ph = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).height;
    System.out.println("w="+w+", h="+h+" - pw="+pw+", ph="+ph);
    Image cim = createImage(pw, ph);
    cim.getGraphics().drawImage(im,0,0, this);                     
    Cursor Custom_Cursor = tk.createCustomCursor(cim,new Point(0,0),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The System.out.println statement prints: w=18, h=13 - pw=32, ph=32
    If I try to do the createImage with w and h instead of pw and ph the same gray square (32,32) is created, and in addition the cursor's size is too big which was the probem to begin with ...
    - bjorn

  • Custom cursor using startDrag

    Hello everyone,
    I have a movieclip following my mouse to act as a custom cursor.
    I am using startDrag on the movie clip and mouse.hide()
    What I am trying to resolve is the following:
    I have several hidden simple button objects in the background of my flash movie. ( I am using these to detect when the user has the mouse in certain areas of the flash movie)
    When i go to move over these simple buttons, my custom cursor movieclip stops following the mouse cursor.  Normally my cursor would also then change to the Hand cursor, but i disabled that.
    Can anyone think of any method or hack that would make this work for me?  I would like my custom cursor following the mouse pointer at all times even when hovering over a simple button.
    thanks in advance.

    The cursor changes to hand cursor yet?
    When you say "single button Several hidden objects", the number is?

  • How to load and increase size of a custom cursor on a certain monitor (1st or 2nd)?

    In my application I need to load a custom cursor, make it big and display it on the my second monitor in a dual monitor setup to let user click with an additional mouse. I found this thread able to solve the first 2 questions, however the cursor only changes within the VI panel. I had tried but couldn't get a handle to the second monitor, in face, not my primary one as well since I'm not familiar with winapi. I also want to restrict when the user can use the second mouse and only in the second monitor if possible. By the way I am using windows 7 64 bit with Labview 9 32 bit.
    Thanks,

    Ishi,
    More than likely, you are going to have to use Windows OS APIs for this. It sounds like you would like to integrate your program at the operating system level, and will have to make calls to Windows to accomplish this in the proper manner.  You can make calls to Windows in LabVIEW through several methods. Check out this example that sets the position of the cursor via a Call Library Function Node to the Windows SDK.  
    http://zone.ni.com/devzone/cda/epd/p/id/2315
    Cheers,
    Aaron
    National Instruments

  • Custom cursor is too slow in FULL_SCREEN_INTERACTIVE

    My custom cursor is fast in window mode (even maximized) but not in fullscreen where it is really slow.
    Is there a solution to this?

    Dear Rob,
    Thanks for your answer.
    I have put together a simple test case (see attached zip file) and the custom cursor is still "too slow to be usable" in fullscreen mode. Run it and see that the cursor is fast in window mode. Then hit ctrl+enter to go into fullscreen and see how slow the cursor becomes.
    Code:
    package
    import flash.events.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.ui.Mouse;
    import flash.ui.Keyboard;
    import flash.display.StageDisplayState;
    import flash.display.MovieClip;
    public class Main extends MovieClip
    private var _mousePointer:MousePointer;
    public function Main()
    super();
    Mouse.hide();
    _mousePointer = new MousePointer();
    addChild(_mousePointer);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardDown);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoved);
    private function goFullscreen(fullscreen:Boolean)
    if(fullscreen)
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
    else
    stage.displayState = StageDisplayState.NORMAL;
    private function onMouseMoved(evt:MouseEvent)
    _mousePointer.x = mouseX;
    _mousePointer.y = mouseY;
    evt.updateAfterEvent();
    private function onKeyboardDown(evt:KeyboardEvent)
    if(evt.controlKey && evt.keyCode == Keyboard.ENTER)
    goFullscreen(stage.displayState == StageDisplayState.NORMAL);

  • Custom Cursor and Drag Image in 1.4 DnD

    What is the proper way to provide a custom cursor and drag image in 1.4 DnD? Say we initiate the drag on a component that supports data transfer (such as a JTree).

    Well, this is strange. My app was locking up (100% CPU) when using DND from windows Explorer.
    I noticed that another part of the same appliction was working perfictly. The difference: JFrame .vs. JDialog. I switched the offending JDialog to a JFrame and all works perfictly now!
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    I would like to switch back at some point, but my g.setXORMode() problem is a much bigger issue for us. (That is, once you enter the XOR mode, you can not go back!)

  • CS6 - Custom Cursor & Button's icon

    I am trying to display a custom cursor when mouse is moving on a button which has icon.
    But the button's icon is always in front of my cursor image.
    How to make my cursor image on top?
    Belows is my code. Please tell me what's wrong.
    Thank you!
    <mx:Application... creationComplete = "init()>
    private var MyCursor:Shape = new Shape();
    private function init():void{
        // draw custom cursor
        MyCursor.graphics.clear();
        MyCursor.graphics.lineStyle(2, 0xFF0000, 1,true);
        MyCursor.graphics.drawCircle(0,0,6);
        MyCursor.graphics.moveTo(-3,-3);
        MyCursor.graphics.lineTo(4,4);
        MyCursor.visible = false;
        // add to the layer
        CursorLayer.addChild(MyCursor);
    private function ShowCustomCursor(e: MouseEvent):void
        Mouse.hide();
        MyCursor.x = e.stageX;
        MyCursor.y = e.stageY;
        MyCursor.visible = true;
    private funtion HideCustomCursor(e:MouseEvent):void
        Mouse.show();
        MyCursor.visible = false;
    <mx:UIComponent id = "CursorLayer" x ="0' y="0" width ="1000" height = "1000" blendMode="layer">
    <mx:Button id="btnTest" x="50" y="5" width="28" height="20" buttonMode="true"
    icon="@Embed(source='assets/btnTest.png')"
    mouseFocusEnabled="true"
    mouseMove="ShowCustomCursor(event)"
    mouseOut="HideCustomCursor(event)"
    tabEnabled="false"
    useHandCursor="true"/>

    that's because your cursor is sporadically moving over your interactive objects interfering with their mouseevents.
    to remedy, disable the mouseEnabled property of your cursor.

  • Adding a custom cursor to a panel

    HI, I am making a game where i want clicking a radio button to change the cursor image. I have figured out how to create a custom cursor, and even change the current cursor to it. The problem im having is i want to change it while the program is running. I can say somthing like frame.addCursor(cursor) but that sets it permenantly. What i would like is to add it to a panel during run-time. If anyone knows how i would go abou this i would be gratefull.
    Thanks

    Do u mean, upon selecting the radio button, the cursor must be changed to the customized one?
    If it is so,
    u add the snippet in the itemStateChanged() event....of the radiobutton
    i.e.,
    public void itemStateChanged(ItemEvent ie)
    if(ie.getStateChange() == ItemEvent.SELECTED)
    myPanel.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(CursorImg, new Point
    (0,0), "MyCursorImg"));
    CursorImg - the image to display when the cursor is actived
    new Point(0,0) - hotSpot
    MyCursorImg - a localized description of the cursor, for Java Accessibility use
    else
    myPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }

  • Custom Cursors with AS3

    I used the code snippets to create a custom cursor and it works well.  What if I want that cursor to change when it's clicked?  Can I do that easy enough?  Thanks.

    you can use a stage mousedown listener to make it appear your cursor was clicked.

  • Custom Cursors with rollovers.

    So I know how to make a custom Cursor in flash Pro CS5 but if I want that custom cursor to change to something else of my own design when it's over specific objects how would I go about doing that?

    So here's the code for both both buttons and their rollover actions.  Like I said it works fine for one but not the other.  The forward button is fine, but when the back button is clicked it leaves behind a stamp of the rollover cursor.
    /* Mouse Over Event
    Mousing over the symbol instance executes a function in which you can add your own custom code.
    Instructions:
    1. Add your custom code on a new line after the line that says "// Start your custom code" below.
       The code will execute when the symbol instance is moused over.
    backbtn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);
    function fl_MouseOverHandler_2(event:MouseEvent):void
    parent.addChild(backphoto);
    backphoto.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_2);
    function fl_CustomMouseCursor_2(event:Event)
              backphoto.x = stage.mouseX;
              backphoto.y = stage.mouseY;
    Mouse.hide();
    /* Mouse Out Event
    Mousing out of the symbol instance executes a function in which you can add your own custom code.
    Instructions:
    1. Add your custom code on a new line after the line that says "// Start your custom code" below.
       The code will execute when the symbol instance is moused out of.
    backbtn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_2);
    function fl_MouseOutHandler_2(event:MouseEvent):void
    parent.removeChild(backphoto);
    Mouse.show();
    /* Mouse Over Event
    Mousing over the symbol instance executes a function in which you can add your own custom code.
    Instructions:
    1. Add your custom code on a new line after the line that says "// Start your custom code" below.
       The code will execute when the symbol instance is moused over.
    Forwardbtn.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
    function fl_MouseOverHandler(event:MouseEvent):void
    {stage.addChild(nextphoto);
    nextphoto.mouseEnabled = false;
    nextphoto.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
    function fl_CustomMouseCursor(event:Event)
              nextphoto.x = stage.mouseX;
              nextphoto.y = stage.mouseY;
    Mouse.hide();
    /* Mouse Out Event
    Mousing out of the symbol instance executes a function in which you can add your own custom code.
    Instructions:
    1. Add your custom code on a new line after the line that says "// Start your custom code" below.
       The code will execute when the symbol instance is moused out of.
    Forwardbtn.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
    function fl_MouseOutHandler(event:MouseEvent):void
    stage.removeChild(nextphoto);
    Mouse.show();

  • Using custom cursor

    I want to use a cursor from file in my page. How can I do
    this?
    I've found:
    <style>
    <!--
    BODY{
    cursor:url("3dwmove.cur");
    -->
    </style>
    but works only in IE and for all page not only for a link for
    example.

    You can't. Custom cursors are a pain for your visitor, many
    (most? all?)
    of whom will not want to download and install something from
    a site.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Flesky" <[email protected]> wrote in
    message
    news:ehi23v$653$[email protected]..
    >I want to use a cursor from file in my page. How can I do
    this?
    >
    > I've found:
    > <style>
    > <!--
    > BODY{
    > cursor:url("3dwmove.cur");
    > }
    > -->
    > </style>
    >
    > but works only in IE and for all page not only for a
    link for example.
    >

  • 16.0.3: custom cursor for third party plugin missing

    We are using a third party plugin which has its own cursor (probably 16x16 png), and after upgrade to AI 16.0.3 on Mac OS 10.8, iMac, the custom cursor just gone, currently it ues system cursor (a black arrow).
    Any detailed info about this upgrade may cause the problem?

    So, here's what happened. In the 16.0.3/16.2 update, Adobe broke sAIUser->SetCursor(). Any plug-in that was using this call to display cursors will no longer be able to change their cursors on Mac. Cursors did not break on Windows. There are two options for developers; either change to platform cursors or wait for Adobe to issue a fix (I do not know, however, if one is planned). Hot Door has already changed to platform cursors and will be issuing an update later this week. There is a discussion on StackOverflow for those interested in the programming solution.

  • Custom Cursor point style on XY graph

    Is there is a way you can change the point style of a cursor on an xy graph to somthing custom, possibly an image or somthing else. Basicly Id like to have very many point styles, but more then just whats in LV, Id want some that actually look different.
    Thanks,
    -Mark

    Hi Mark,
    You can use an event structure to detect when the mouse enters or leaves the XY graph. When the mouse enters you can set the cursor using the "Set Cursor" VI and when it leaves you can unset the cursor using the "Unset Busy" VI. You can create a reference to a custom cursor beforehand using the "Create Cursor from file" VI. Unfortunately none of the VIs that I mention here are available with the base package.
    I've attached an example program written in LV7 on Windows. (note: you need a .ani or .cur file for the cursor you wish to use)
    Hope this helps,
    Neil
    Attachments:
    XY_Cursor.vi ‏83 KB

  • Custom cursor that follows mouse - JITTERS

    Hi again.
    I'm using this code to make my custom cursor follow the mouse, HOWEVER when it gets near to the mouth it goes loopy - and turns left and right in a fit. Can I put code in there for it to be smoother?
    The CODE is lower done highlighted in BLACK.
    Cheers
    // Remeber to add private to vars and public to functions that are used outside.
    import flash.display.MovieClip;
    import flash.media.Sound;
    import flash.events.Event;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;
    var v:Number=5;
    var varObject:String;
    var i:Number;
    var arrayObjects:Array;
    var soundClip:Sound;
    var randomnumber:Number;
    //public function game1SunnyWalk() {
    stage.addEventListener(MouseEvent.MOUSE_MOVE, myClickReaction);
    stage.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    // populate array and initiate variables i and varObject
    this.arrayObjects=["chocolate","icecream","pizza","hamburger","sandwich","egg"];
    this.i=1;
    this.varObject=arrayObjects[i-1];
    var clickPoint:Point = new Point();
    function myClickReaction(e:MouseEvent):void {
    clickPoint.x=this.mouseX;
    clickPoint.y=this.mouseY;
    function onEnterFrame(event:Event):void {
    var xDistance:Number=clickPoint.x-this.planeAndSunny.x;
    var yDistance:Number=clickPoint.y-this.planeAndSunny.y;
    var angle:Number=Math.atan2(yDistance,xDistance);
    this[varObject].y += 5;
    //trace(this[varObject].y);
    this.planeAndSunny.x+=v*Math.cos(angle);
    this.planeAndSunny.y+=v*Math.sin(angle);
    if (clickPoint.x>=planeAndSunny.x) {
    this.planeAndSunny.gotoAndPlay("right");
    //trace(Math.abs(xDistance));
    if (this.planeAndSunny.x>=clickPoint.x) {
    this.planeAndSunny.gotoAndPlay("left");
    //trace(Math.abs(xDistance));
    //if (Math.abs(xDistance)<=10) {
    //trace("works");
    //this.planeAndSunny.gotoAndPlay("static");
    //removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    function enterFrameHandler(e:Event):void {
    varObject=arrayObjects[i-1];
    // this property refers to the mc being referenced and as it's an array you also need the square brackets
    // I tried to hitTest only the STRING whereas you need to hitTest the object
    // ie: this refers to the array object and NOT the string.
    if (this.planeAndSunny.hitTestObject(this[varObject])) {
    //starts sound
    //init();
    // spins the object
    spin();
    trace(varObject);// BUT you can trace the STRING ie: No need to use OBJECT(STRING) - which would be the actual mc.
    removeEventListener(Event.ENTER_FRAME, enterFrameHandler);// ie: You can't do a hitTest on a string BUT on an object. (The array)
    //var soundClip:Sound;
    //function init() {
    //soundClip = new Sound();
    //soundClip.load(new URLRequest("sound/chocolate.mp3"));
    //soundClip.addEventListener(Event.COMPLETE, soundLoaded);
    //soundClip.addEventListener(ProgressEvent.PROGRESS, soundLoading);
    //function soundLoaded(e:Event) {
    //soundClip.play();
    function spin() {
    //tw.addEventListener(TweenEvent.MOTION_FINISH, spinStopped);// note than when you use addEventListener - the function called uses that event as an argument in brackets after the function name
    var tw:Tween=new Tween(this[varObject],"rotation",Strong.easeOut,0,360,2,true);
    var numturns:int=8;
    this[varObject].removeEventListener(MouseEvent.CLICK, spin);
    tw.begin=this[varObject].rotation;
    tw.finish=numturns*360;
    tw.start();
    i=i+1;

    you can easily attach the cursor between the specific layers you want using an empty movieclip and add your cursor movieclip to the emptyMC using the class name. Look at the screenshot and follow the code. it works
    and here is the code:
    import flash.display.MovieClip;
    var whytehand:MovieClip=new cur();
    emptyMC.addChild(whytehand);
    emptyMC.mouseEnabled = false;
    emptyMC.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_5);
    function fl_CustomMouseCursor_5(event:Event)
        emptyMC.x = stage.mouseX;
        emptyMC.y = stage.mouseY;
    Mouse.hide();
    Thatz it!

  • Custom cursor click

    I'm using this to create a custom cursor and to use a mouse click event on a movieclip:
    stop();
    Mouse.hide();
    stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
    function follow(evt:MouseEvent)
              cursor_mc.x = mouseX;
              cursor_mc.y = mouseY;
    volgendePijlClip.addEventListener(MouseEvent.CLICK, pijlEventClip);
    function pijlEventClip(event:MouseEvent):void
              trace(1)
    At first it didn't work for me, but I found out that was because the custom cursor was over its registration point. Which was made equal to the mouse's location. So when the mouse was clicked on the movieclip-button, it was actually clicking on the custom mouse cursor itself, so the click on the 'volgendePijlClip movieclip wasn't picked up on.
    I solved it by moving the custom cursor slightly away from it's registration point, so it would appear slightly of mouseX/mouseY. Close enough to act as cursor, but away of the cursor enough so the hidden mouse cursor could pick up a click on 'volgendePijlClip'.
    Was wondering if there still was a way for a custom cursor to be over it's registration point and have the hidden mouse cursor still pick up on clicking on objects beneath the custom cursor?

    assign its mouseEnabled property to false:
    cursor_mc.mouseEnabled=false;

Maybe you are looking for

  • Applescript, Illustrator CS5 and Saving as a PDF

    Hello, First I'm not sure if this is the best spot to post this but I figure I would start here! I'm a rookie applescripter and can find code and piece it together to get things done. The issue I've recently come across has to do with saving files as

  • Kerberos problem on Mac OS X Server

    Hi, Our corporate using Mac OS X 10.6.x server on Xserve, users can login server daily using OD with Kerberos enabled, they can also access files from the file server with no any problem, but if I run kinit <userid> and then type the password, it dis

  • Creating Rule PFAC_INS

    Dear All... I created a rule (using tcod pfac_ins) for determining agents for approval workflow and i used "agent determination :Responsibility" rule Category. when i assign  agents ( user type ) to a responsibility. the agents is ordered by alphabet

  • AirPort card not working ... mostly

    This is one that has me a bit stumped. I have a G3 iBook with the original airport card installed. Yesterday, it stopped recognizing any wireless networks in the local area (I have one graphite ABS and one AirPort Express, plus there are one or two o

  • What if i don't like the app?

    mmm... buying from the app store, now here's a question; what if i buy something and don't like it? it's very possible, i mean, you don't to try on these shoes before you buy them.