Bug 405813 - Implement AccessibleHyperlinkListener methods
Summary: Implement AccessibleHyperlinkListener methods
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: accessibility, triaged
Depends on:
Blocks: 517380
  Show dependency tree
 
Reported: 2013-04-16 14:23 EDT by Carolyn MacLeod CLA
Modified: 2021-02-04 13:49 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carolyn MacLeod CLA 2013-04-16 14:23:56 EDT
The AccessibleHyperlinkListener methods are missing on GTK.
These methods are:
getAnchor(AccessibleHyperlinkEvent)
getAnchorTarget(AccessibleHyperlinkEvent)
getStartIndex(AccessibleHyperlinkEvent)
getEndIndex(AccessibleHyperlinkEvent)

The AtkHyperlink interface methods can be used for the implementation: 
(from https://developer.gnome.org/atk/unstable/AtkHyperlink.html )

gchar *      atk_hyperlink_get_uri          (AtkHyperlink *link_, gint i);
AtkObject *  atk_hyperlink_get_object       (AtkHyperlink *link_, gint i);
gint         atk_hyperlink_get_start_index  (AtkHyperlink *link_);
gint         atk_hyperlink_get_end_index    (AtkHyperlink *link_);
Comment 1 Carolyn MacLeod CLA 2013-04-16 16:07:17 EDT
These methods are missing on Mac also.
Comment 2 Carolyn MacLeod CLA 2013-04-16 16:10:37 EDT
Here is a snippet that might be useful for testing:

package accessibility;
//package org.eclipse.swt.snippets;

import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
 * StyledText snippet: embed controls
 *
 * For a list of all SWT example snippets see
 * http://www.eclipse.org/swt/snippets/
 * 
 * @since 3.2
 */
public class Snippet217b {
 
 static StyledText styledText;
 static String text = 
  "This snippet shows how to embed widgets in a StyledText.\n"+
  "A button: \uFFFC, a combobox: \uFFFC, and a link: \uFFFC.";
 static int MARGIN = 5;
 static final int BUTTON_INDEX = 0;
 static final int COMBO_INDEX = 1;
 static final int LINK_INDEX = 2;
 
 static void addControl(Control control, int offset) {
  StyleRange style = new StyleRange ();
  style.start = offset;
  style.length = 1;
  style.data = control;
  control.pack();
  Rectangle rect = control.getBounds();
  int ascent = 2*rect.height/3;
  int descent = rect.height - ascent;
  style.metrics = new GlyphMetrics(ascent + MARGIN, descent + MARGIN, rect.width + 2*MARGIN);
  styledText.setStyleRange(style); 
 }
 
 public static void main(String [] args) {
  final Display display = new Display();
  Font font = new Font(display, "Tahoma", 16, SWT.NORMAL);
  final Shell shell = new Shell(display);
  shell.setLayout(new GridLayout());
  
  // Create the styled text; embedded controls are placed at \uFFFC in the text.
  styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
  styledText.setFont(font);
  styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
  styledText.setText(text);
  
  // Create the button
  final Button button = new Button(styledText, SWT.PUSH);
  button.setText("Button 1");
  final int buttonOffset = text.indexOf('\uFFFC');
  addControl(button, buttonOffset);
  button.setLocation(styledText.getLocationAtOffset(buttonOffset));
  
  // Create the combobox
  final Combo combo = new Combo(styledText, SWT.NONE);
  combo.add("item 1");
  combo.add("another item");
  combo.setText(combo.getItem(0));
  final int comboOffset = text.indexOf('\uFFFC', buttonOffset + 1);
  addControl(combo, comboOffset);
  combo.setLocation(styledText.getLocationAtOffset(comboOffset));
  
  // Create the Link
  final Link link = new Link(styledText, SWT.NONE);
  String text2 = "<a href=\"http:\\\\www.eclipse.org\">www.eclipse.org</a>";
  link.setText(text2);
  link.setSize(400, 400);
  link.addListener (SWT.Selection, new Listener () {
	public void handleEvent(Event event) {
		System.out.println("Selection: " + event.text);
	}
  });
  final int linkOffset = text.indexOf('\uFFFC', comboOffset + 1);
  addControl(link, linkOffset);
  combo.setLocation(styledText.getLocationAtOffset(linkOffset));	
  
  // use a verify listener to dispose the controls
  styledText.addVerifyListener(new VerifyListener()  {
   public void verifyText(VerifyEvent event) {
    if (event.start == event.end) return;
    String text = styledText.getText(event.start, event.end - 1);
    int index = text.indexOf('\uFFFC');
    while (index != -1) {
     StyleRange style = styledText.getStyleRangeAtOffset(event.start + index);
     if (style != null) {
      Control control = (Control)style.data;
      if (control != null) control.dispose();
     }
     index = text.indexOf('\uFFFC', index + 1);
    }
   }
  });
  
  // reposition widgets on paint event
  styledText.addPaintObjectListener(new PaintObjectListener() {
   public void paintObject(PaintObjectEvent event) {
    Control control = (Control)event.style.data;
    Point pt = control.getSize();
    int x = event.x + MARGIN;
    int y = event.y + event.ascent - 2*pt.y/3;
    control.setLocation(x, y);
   }
  });
  
  styledText.getAccessible().addAccessibleTextListener(new AccessibleTextExtendedAdapter() {
   public void getHyperlinkCount(AccessibleTextEvent e) {
    e.count = 3;
   }
   public void getHyperlink(AccessibleTextEvent e) {
    if (e.index == BUTTON_INDEX) {
     e.accessible = button.getAccessible();
     e.accessible.addAccessibleHyperlinkListener(new AccessibleHyperlinkAdapter() {
      public void getStartIndex(AccessibleHyperlinkEvent e) {
       e.index = buttonOffset;
      }
      public void getEndIndex(AccessibleHyperlinkEvent e) {
       e.index = buttonOffset;
      }
      public void getAnchor(AccessibleHyperlinkEvent e) {
       e.result = "this is the anchor?? for the button";
      }
      public void getAnchorTarget(AccessibleHyperlinkEvent e) {
       e.result = "http://www.ibm.com";
      }
     });
    }
    else if (e.index == COMBO_INDEX) {
     e.accessible = combo.getAccessible();
     e.accessible.addAccessibleHyperlinkListener(new AccessibleHyperlinkAdapter() {
      public void getStartIndex(AccessibleHyperlinkEvent e) {
       e.index = comboOffset;
      }
      public void getEndIndex(AccessibleHyperlinkEvent e) {
       e.index = comboOffset;
      }
      public void getAnchor(AccessibleHyperlinkEvent e) {
       e.result = "this is the anchor?? for the combo";
      }
      public void getAnchorTarget(AccessibleHyperlinkEvent e) {
       e.result = "http://www.cnn.com";
      }
     });
    }
    else if (e.index == LINK_INDEX) {
        e.accessible = link.getAccessible();
        e.accessible.addAccessibleHyperlinkListener(new AccessibleHyperlinkAdapter() {
         public void getStartIndex(AccessibleHyperlinkEvent e) {
          e.index = linkOffset;
         }
         public void getEndIndex(AccessibleHyperlinkEvent e) {
          e.index = linkOffset;
         }
         public void getAnchor(AccessibleHyperlinkEvent e) {
          e.result = "this is the anchor?? for the combo";
         }
         public void getAnchorTarget(AccessibleHyperlinkEvent e) {
          e.result = "http://www.eclipse.org";
         }
        });
       }
   }
   public void getHyperlinkIndex(AccessibleTextEvent e) {
    if (e.offset == buttonOffset) e.index = 0;
    else if (e.offset == comboOffset) e.index = 1;
    else e.index = -1;
   }
  });
   
  shell.setSize(400, 400);
  shell.open();
  while (!shell.isDisposed()) {
   if (!display.readAndDispatch())
    display.sleep();
  }
  font.dispose();
  display.dispose();
 }
}
Comment 3 Eclipse Genie CLA 2021-02-04 13:49:26 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.