Posted to tcl by emiliano at Tue Nov 12 00:55:44 GMT 2024view raw

  1. int
  2. Tk_SetAccessibleRole(
  3. TCL_UNUSED(void *),
  4. Tcl_Interp *ip, /* Current interpreter. */
  5. int objc, /* Number of arguments. */
  6. Tcl_Obj *const objv[]) /* Argument objects. */
  7. {
  8. Tk_Window win;
  9. Tcl_HashEntry *hPtr, *hPtr2;
  10. int isNew;
  11. Tcl_HashTable *AccessibleAttributes;
  12.  
  13. if (objc < 3) {
  14. Tcl_WrongNumArgs(ip, 1, objv, "window role");
  15. return TCL_ERROR;
  16. }
  17.  
  18. win = Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));
  19. if (win == NULL) {
  20. return TCL_ERROR;
  21. }
  22. /* Set accessible role for window. */
  23. hPtr = Tcl_CreateHashEntry(TkAccessibilityObject, win, &isNew);
  24. if (isNew) {
  25. AccessibleAttributes = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
  26. Tcl_InitHashTable(AccessibleAttributes,TCL_STRING_KEYS);
  27. Tcl_SetHashValue(hPtr, AccessibleAttributes);
  28. } else {
  29. AccessibleAttributes = Tcl_GetHashValue(hPtr);
  30. }
  31.  
  32. hPtr2 = Tcl_CreateHashEntry(AccessibleAttributes, "role", &isNew);
  33. if (!isNew) {
  34. Tcl_DecrRefCount(Tcl_GetHashValue(hPtr2));
  35. }
  36. Tcl_IncrRefCount(objv[2]);
  37. Tcl_SetHashValue(hPtr2, objv[2]);
  38.  
  39. Tcl_SetObjResult(ip, Tcl_GetHashValue(hPtr2));
  40. return TCL_OK;
  41. }
  42.