xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Ganir <philliprs_y...@yahoo.com>
Subject Re: On Changing the Mouse Cursor Appearance
Date Sun, 11 Jun 2006 05:13:04 GMT
Andreas Neumann <neumann <at> karto.baug.ethz.ch> writes:

> >     I tried including a cursor attribute in the rect element, such as:
> >
> >     <rect id="BaseRectangle" x="0" y="0" height="300" width="515" 
> >cursor="default"/>
> >
> >  
> >
> yes, that cursor attribute is correct. But it is not clear from your 
> example whether you have an event listener attached or not. You could 
> either do it by using the "on..." event handler attributes or by using 
> elt.addEventListener(listenertype,functionOrObject,bubblingOrCapturephase);

       Actually, I've already added event listeners by calling this function 
we made whenever a rectangle is added in the svg so every rectangle has an 
event listener. We tested this already with other events concerning changing 
attributes of the rect element and it's successful:

     addListener( Element elt)
          Element element = elt;
          EventTarget event = (EventTarget) element;
          event.addEventListener( "mousedown", downPt, false );   

     Where downPt is an instance of a class that with an event hanling 
function that changes the value of the cursor attribute with the following 

     if(xDown >= rectLeftPart && xDown <= rectRightPart)
     ( (Element) evt.getTarget() ).setAttributeN(null,   
                "cursor", "crosshair");
     if(xDown > rectRightPart)
     ( (Element) evt.getTarget() ).setAttributeNS( null, "cursor", "e-resize");
     if(xDown < rectLeftPart)
     ( (Element) evt.getTarget() ).setAttributeNS( null, "cursor", "w-resize");
     where xDown is the point where the mouse is clicked and rectLeftPart and 
rectRightPart are respectively the area < 0.1* rectangle's width and >0.9* 
rectangle's width (i.e., the leftmost 10% and rightmost 10% of the rectangle's 
width). So I think there should be no problem meanwhile I haven't created 
invisible rectangles encapsulating the rect element (although it's a good idea 
that we were also planning before). 

> >    and I change the attribute's value to a type I want in the event 
> >
> >     ( (Element) evt.getTarget() ).setAttribut("cursor", "w-resize" );
> >
> >  
> >
> the correct syntax would be:
> evt.target.setAttributeNS(null,"cursor","w-resize");

     The dropdown menu don't have this exact syntax. Actually we tried the 
syntax i mentioned above with other attributes and they were successully 
changed. I'm also printing the changes in the cursor attribute and it's being 
chnaged successfully. But, the changes doesn't manifest visibly. What could be 
> depending on what you want to do it might also make sense to have the 
> event listener not on the rectangle but on the document or a parent 
> group or an invisible element that is slightly bigger than your 
> rectangle, because you probably want to set the cursor also on the edge 
> or slightly outside the rectangle within a sensitive edge around the 
> rectangle.
> >     Is there anything I'm doing wrong or anything I'm lacking to do?
> >
> >     I also tried including cursor and pointer-events (with value "fill")
> >attribute at the svg (root) element and also the latter to the rect 
> >but nothing changes.
> >  
> >
> no need to set the pointer-events attribute. The default value is "fill" 
> anyway.

     But, is this attribute needed to be in every element and in the root or 
just either? Although I tried both. :) 
> Andreas

     Thanks a lot for your initial reply! I hope there's next. :)


To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message