Posted to tcl by kevin_walzer at Wed Oct 30 02:31:25 GMT 2024view raw
- char *acc_role, *acc_name, *acc_description, *acc_value, *acc_state, *acc_action;
- /* Hash table for storing accessible window attributes. */
- Tcl_HashTable *AccessibleObject;
- int
- Tk_AccessibleRole(
- TCL_UNUSED(void *),
- Tcl_Interp *ip, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
- {
- if (objc < 3) {
- Tcl_WrongNumArgs(ip, 1, objv, "window? role?");
- return TCL_ERROR;
- }
- Tk_Window win;
- Tcl_Obj *obj;
- Tcl_Size arg_length;
- const char *role;
- Tcl_HashEntry *hPtr = NULL;
- Tcl_HashEntry *hPtr2 = NULL;
- int isNew = 0;
- Tcl_InitHashTable (&AccessibleObject, TCL_STRING_KEYS);
- /* Attribute hash table. */
- Tcl_HashTable *attributeTbl;
- if (attributeTbl == NULL) {
- Tcl_InitHashTable(&attributeTbl, TCL_STRING_KEYS);
- }
- win = Tk_NameToWindow(ip, Tcl_GetString(objv[1]), Tk_MainWindow(ip));
- if (win == NULL) {
- return TCL_ERROR;
- }
- /* Get accessibility role for window. */
- obj = objv[2];
- role = Tcl_GetStringFromObj(obj, &arg_length);
- acc_role = (char*)role;
- hPtr = Tcl_CreateHashEntry(AccessibleObject,
- Tk_PathName(win), &isNew);
- Tcl_SetHashValue(hPtr, attributeTbl);
- hPtr2 = Tcl_CreateHashEntry(attributeTbl, acc_role, &isNew);
- Tcl_SetHashValue(hPtr2, acc_role);
- return TCL_OK;
- }