Posted to tcl by kevin_walzer at Wed Oct 30 02:31:25 GMT 2024view raw

  1. char *acc_role, *acc_name, *acc_description, *acc_value, *acc_state, *acc_action;
  2.  
  3. /* Hash table for storing accessible window attributes. */
  4. Tcl_HashTable *AccessibleObject;
  5.  
  6. int
  7. Tk_AccessibleRole(
  8. TCL_UNUSED(void *),
  9. Tcl_Interp *ip, /* Current interpreter. */
  10. int objc, /* Number of arguments. */
  11. Tcl_Obj *const objv[]) /* Argument objects. */
  12. {
  13. if (objc < 3) {
  14. Tcl_WrongNumArgs(ip, 1, objv, "window? role?");
  15. return TCL_ERROR;
  16. }
  17.  
  18. Tk_Window win;
  19. Tcl_Obj *obj;
  20. Tcl_Size arg_length;
  21. const char *role;
  22. Tcl_HashEntry *hPtr = NULL;
  23. Tcl_HashEntry *hPtr2 = NULL;
  24. int isNew = 0;
  25.  
  26.  
  27. Tcl_InitHashTable (&AccessibleObject, TCL_STRING_KEYS);
  28.  
  29. /* Attribute hash table. */
  30. Tcl_HashTable *attributeTbl;
  31.  
  32. if (attributeTbl == NULL) {
  33. Tcl_InitHashTable(&attributeTbl, TCL_STRING_KEYS);
  34. }
  35.  
  36. win = Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));
  37. if (win == NULL) {
  38. return TCL_ERROR;
  39. }
  40.  
  41. /* Get accessibility role for window. */
  42.  
  43. obj = objv[2];
  44. role = Tcl_GetStringFromObj(obj, &arg_length);
  45. acc_role = (char*)role;
  46. hPtr = Tcl_CreateHashEntry(AccessibleObject,
  47. Tk_PathName(win), &isNew);
  48. Tcl_SetHashValue(hPtr, attributeTbl);
  49. hPtr2 = Tcl_CreateHashEntry(attributeTbl, acc_role, &isNew);
  50. Tcl_SetHashValue(hPtr2, acc_role);
  51. return TCL_OK;
  52. }