Posted to tcl by emiliano at Tue Nov 12 00:55:44 GMT 2024view raw
- int
- Tk_SetAccessibleRole(
- TCL_UNUSED(void *),
- Tcl_Interp *ip, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
- {
- Tk_Window win;
- Tcl_HashEntry *hPtr, *hPtr2;
- int isNew;
- Tcl_HashTable *AccessibleAttributes;
- if (objc < 3) {
- Tcl_WrongNumArgs(ip, 1, objv, "window role");
- return TCL_ERROR;
- }
- win = Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));
- if (win == NULL) {
- return TCL_ERROR;
- }
- /* Set accessible role for window. */
- hPtr = Tcl_CreateHashEntry(TkAccessibilityObject, win, &isNew);
- if (isNew) {
- AccessibleAttributes = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
- Tcl_InitHashTable(AccessibleAttributes,TCL_STRING_KEYS);
- Tcl_SetHashValue(hPtr, AccessibleAttributes);
- } else {
- AccessibleAttributes = Tcl_GetHashValue(hPtr);
- }
- hPtr2 = Tcl_CreateHashEntry(AccessibleAttributes, "role", &isNew);
- if (!isNew) {
- Tcl_DecrRefCount(Tcl_GetHashValue(hPtr2));
- }
- Tcl_IncrRefCount(objv[2]);
- Tcl_SetHashValue(hPtr2, objv[2]);
- Tcl_SetObjResult(ip, Tcl_GetHashValue(hPtr2));
- return TCL_OK;
- }