• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text.


  • Subject: Re: Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text.
  • From: Patti Hoa <email@hidden>
  • Date: Mon, 29 Nov 2010 16:08:05 -0800

Try kAXRangeForPositionParameterizedAttribute to get the text range under the mouse.  Then use this range for kAXAttributedStringForRangeParameterizedAttribute to get to attributed string.   Then you can get all sorts of text style information via the dictionary of the attributed string.

Note that you should use AXUIElementCopyParameterizedAttributeValue API to fetch any parameterized attribute, passing the parameter for the third argument.  
For example, the parameter to pass in to fetch kAXRangeForPositionParameterizedAttribute should be a CFTypeRef variable, created via AXValueCreate API.

Here's how the code can look like:
CGPoint mousePoint = {55, 100};
CFTypeRef parameter = AXValueCreate( kAXValueCGPointType, (void *)&mousePoint );
CFTypeRef value = NULL;
AXError error = AXUIElementCopyParameterizedAttributeValue( axElementRef, kAXRangeForPositionParameterizedAttribute, parameter, &value );
CFRelease(parameter);

if ( value != nil && AXValueGetType(value) == kAXValueCFRangeType ) {
   // once you are here, then you've got the range for the given mouse position
   NSRange range = {0,0};
   BOOL status = AXValueGetValue(value, kAXValueCFRangeType, (void *)&range);
   if (!status) 
// failed to fetch the range
   else
       // got the range, return this NSRange
}


Patti


On Nov 29, 2010, at 12:58 AM, manoj wrote:

Hi All,
  I wanted to retrieve the text related information (like text's font size,name,color etc..) when mouse cursor is placed over the text.
  Following ways are tried:

 1) Description given in AxTextAttributedString.h
 If an accessibility object represents an attributed string, the value of its attribute is an attributed string object (a CFAttributedStringRef or an NSAttributedString) that uses the constants defined in this header file to define its attributes.
         -I have not seen any ways by which can get  kAXParameterizedAttributeStringAttribute.

2) Don't have idea about third parameter in AXUIElementCopyParameterizedAttributeValue():
NSArray *parameterizedAttributeNames = nil; 
         AXUIElementCopyParameterizedAttributeNames(
        AXUIElementRef element,
        CFArrayRef *names); 

//AXUIElementRef element;
                   //AXUIElementCopyParameterizedAttributeNames(element, (CFArrayRef *)&parameterizedAttributeNames);

By using above method,I get All parametrized attribute name.But when i tried to access values of those attriibute names by 
  AXUIElementCopyParameterizedAttributeValue (
         AXUIElementRef element,
         CFStringRef parameterizedAttribute,
         CFTypeRef parameter,
         CFTypeRef *result);

  -Didn't get any idea about what to provide in third parameter. 



3) Tried to replace AXUIElementCopyParameterizedAttributeValue (
    AXUIElementRef element,
    CFStringRef parameterizedAttribute,
    CFTypeRef parameter,
  CFTypeRef *result);
                                        by 
  AXUIElementCopyAttributeValue (
  AXUIElementRef element,
    CFStringRef attribute,
    CFTypeRef *value); .
-It returns NULL in value.


4) Use of kAXAttributedStringForRangeParameterizedAttribute

   Description: The CFAttributedStringType representation of the text associated with this accessibility object that is specified by the given range.

   Also by passing this parametrized attribute to AXUIElementCopyParameterizedAttributeValue(element,kAXAttributedStringForRangeParameterizedAttribute, parameterValue,(CFTypeRef*)value), It gives NULL in value.

    (Don't hvae any idea about third parameter so had parameter by creating it from AXValueCreate(). 

NSPoint point = [NSEvent mouseLocation];
 CFTypeRef parameterValue = AXValueCreate(kAXValueCGPointType, &point);)

    

   Can kAXAttributedStringForRangeParameterizedAttribute parameter will help me to get desired result if I provide third parameter properly?


please suggest me any possible way to get the desired result and also for above mentioned problem.

Thanks in advance.







DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

Do not post admin requests to the list. They will be ignored. Accessibility-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text. (From: manoj <email@hidden>)

  • Prev by Date: Re: Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text.
  • Previous by thread: Re: Retrieve the text related information (like text's font size, name, color etc..) when mouse cursor is placed over the text.
  • Index(es):
    • Date
    • Thread