Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#import <Cocoa/Cocoa.h>
#import <jni.h>

#define INCREMENT @"AXIncrement"
#define DECREMENT @"AXDecrement"

@interface AccessibleBase : NSAccessibilityElement {
@private
jobject jAccessible;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ + (void) initializeRolesMap {
* All JavaFX roles and corresponding available properties are defined in
* enum javafx.scene.AccessibleRole
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:9];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:11];

[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"BUTTON"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"DECREMENT_BUTTON"];
Expand All @@ -53,6 +53,8 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"CHECK_BOX"];
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"TOGGLE_BUTTON"];
[rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"];
[rolesMap setObject:@"JFXStepperAccessibility" forKey:@"SPINNER"];
[rolesMap setObject:@"JFXSliderAccessibility" forKey:@"SLIDER"];

}

Expand Down Expand Up @@ -105,16 +107,35 @@ - (id)accessibilityValue
return variantToID(env, jresult);
}

- (NSString *)accessibilityLabel
- (id)accessibilityMinValue
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NULL;
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
jAccessibilityAttributeValue, (jlong)@"AXMinValue");
GLASS_CHECK_EXCEPTION(env);
return variantToID(env, jresult);
}

- (id)accessibilityMaxValue
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NULL;
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue, (jlong)@"AXTitle");
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
jAccessibilityAttributeValue, (jlong)@"AXMaxValue");
GLASS_CHECK_EXCEPTION(env);
return variantToID(env, jresult);
}

- (NSString *)accessibilityLabel
{
// Use the same value that is set for accessibilityTitle - some component
// do not have titles and request it as a label
return [self accessibilityTitle];
}

- (id)accessibilityParent
{
if (parent == nil) {
Expand All @@ -129,6 +150,30 @@ - (id)accessibilityParent
return parent;
}

- (id)accessibilityTitle
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NULL;
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
jAccessibilityAttributeValue, (jlong)@"AXTitle");
GLASS_CHECK_EXCEPTION(env);
return variantToID(env, jresult);
}
Comment on lines +153 to +162
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is same as accessibilityLabel. Should we change implementation to call one method from the other ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.


- (id)accessibilityTitleUIElement
{
jobject jresult = NULL;
GET_MAIN_JENV;
if (env == NULL) return NULL;
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue,
(jlong)@"AXTitleUIElement");
GLASS_CHECK_EXCEPTION(env);
return variantToID(env, jresult);
}



// Actions support
- (BOOL)performAccessibleAction:(NSString *)action
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import <AppKit/AppKit.h>

@interface JFXSliderAccessibility : AccessibleBase <NSAccessibilitySlider> {

};
- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityLabel;
- (id)accessibilityValue;
- (BOOL)accessibilityPerformDecrement;
- (BOOL)accessibilityPerformIncrement;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "JFXSliderAccessibility.h"

/*
* Implementation of the accessibility peer for the slider role
*/

@implementation JFXSliderAccessibility
- (NSAccessibilityRole)accessibilityRole
{
return NSAccessibilitySliderRole;
}

- (NSString *)accessibilityLabel
{
return [super accessibilityLabel];
}

- (id)accessibilityValue
{
return [super accessibilityValue];
}

- (id)accessibilityTitle
{
return [super accessibilityTitle];
}

- (BOOL)accessibilityPerformIncrement
{
return [self performAccessibleAction:INCREMENT];
}

- (BOOL)accessibilityPerformDecrement
{
return [self performAccessibleAction:DECREMENT];
}

- (NSRect)accessibilityFrame
{
return [super accessibilityFrame];
}

- (id)accessibilityParent
{
return [super accessibilityParent];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import <AppKit/AppKit.h>

@interface JFXStepperAccessibility : AccessibleBase <NSAccessibilityStepper> {

};
- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityLabel;
- (id)accessibilityValue;
- (BOOL)accessibilityPerformDecrement;
- (BOOL)accessibilityPerformIncrement;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "JFXStepperAccessibility.h"

/*
* Implementation of the accessibility peer for the stepper role
*/

@implementation JFXStepperAccessibility
- (NSAccessibilityRole)accessibilityRole
{
return NSAccessibilityIncrementorRole;
}

- (NSString *)accessibilityLabel
{
return [super accessibilityLabel];
}

- (id)accessibilityValue
{
return [super accessibilityValue];
}

- (id)accessibilityMinValue
{
return [super accessibilityMinValue];
}

- (id)accessibilityMaxValue
{
return [super accessibilityMaxValue];
}

- (BOOL)accessibilityPerformIncrement
{
return [self performAccessibleAction:INCREMENT];
}

- (BOOL)accessibilityPerformDecrement
{
return [self performAccessibleAction:DECREMENT];
}

- (NSRect)accessibilityFrame
{
return [super accessibilityFrame];
}

- (id)accessibilityParent
{
return [super accessibilityParent];
}

@end