Skip to content
Snippets Groups Projects
Commit ea88e954 authored by jojohoch's avatar jojohoch
Browse files

[player] Let keyboard and keypad support TextFieldSimpleElements

parent 55eb212c
No related branches found
No related tags found
No related merge requests found
import { TextFieldComponent } from 'common/components/ui-elements/text-field.component';
import { TextAreaComponent } from 'common/components/ui-elements/text-area.component';
import { SpellCorrectComponent } from 'common/components/ui-elements/spell-correct.component';
import { TextFieldSimpleComponent } from 'common/components/ui-elements/text-field-simple.component';
export abstract class InputService {
elementComponent!: TextFieldComponent | TextAreaComponent | SpellCorrectComponent;
elementComponent!: TextFieldComponent | TextAreaComponent | SpellCorrectComponent | TextFieldSimpleComponent;
inputElement!: HTMLTextAreaElement | HTMLInputElement;
isOpen!: boolean;
protected open(focusedElement: HTMLElement | null,
elementComponent: TextAreaComponent | TextFieldComponent | SpellCorrectComponent): boolean {
protected open(focusedElement: HTMLElement | null, elementComponent:
TextAreaComponent | TextFieldComponent | TextFieldSimpleComponent | SpellCorrectComponent
): boolean {
this.inputElement = elementComponent.elementModel.type === 'text-area' ?
focusedElement as HTMLTextAreaElement :
focusedElement as HTMLInputElement;
......
......@@ -12,10 +12,10 @@ import { MessageService } from 'common/services/message.service';
import { VeronaSubscriptionService } from 'verona/services/verona-subscription.service';
import { ValidationService } from '../../services/validation.service';
import { KeypadService } from '../../services/keypad.service';
import { TextFieldComponent } from 'common/components/ui-elements/text-field.component';
import { ElementFormGroupDirective } from '../../directives/element-form-group.directive';
import { KeyboardService } from '../../services/keyboard.service';
import { DeviceService } from '../../services/device.service';
import { TextFieldSimpleComponent } from 'common/components/ui-elements/text-field-simple.component';
@Component({
selector: 'aspect-element-compound-group',
......@@ -58,26 +58,26 @@ export class ElementCompoundGroupComponent extends ElementFormGroupDirective imp
this.elementModelElementCodeMappingService.mapToElementCodeValue(childModel.value, childModel.type),
child,
this.pageIndex);
if (childModel.type === 'text-field') {
const textFieldComponent = child as TextFieldComponent;
(child as TextFieldComponent)
if (childModel.type === 'text-field-simple') {
const textFieldSimpleComponent = child as TextFieldSimpleComponent;
(child as TextFieldSimpleComponent)
.onFocusChanged
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(element => {
this.onFocusChanged(element, textFieldComponent, childModel);
this.onFocusChanged(element, textFieldSimpleComponent, childModel);
});
(child as TextFieldComponent)
(child as TextFieldSimpleComponent)
.onKeyDown
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(element => {
this.registerHardwareKeyboard(element, textFieldComponent);
this.registerHardwareKeyboard(element, textFieldSimpleComponent);
});
}
});
}
private onFocusChanged(inputElement: HTMLElement | null,
elementComponent: TextFieldComponent,
elementComponent: TextFieldSimpleComponent,
elementModel: InputElement): void {
if (elementModel.inputAssistance !== 'none') {
this.isKeypadOpen = this.keypadService.toggle(inputElement, elementComponent);
......@@ -88,7 +88,7 @@ export class ElementCompoundGroupComponent extends ElementFormGroupDirective imp
}
private registerHardwareKeyboard(inputElement: HTMLElement | null,
elementComponent: TextFieldComponent): void {
elementComponent: TextFieldSimpleComponent): void {
this.deviceService.registerHardwareKeyboard();
this.keyboardService.toggle(inputElement, elementComponent, this.deviceService.isMobileWithoutHardwareKeyboard);
}
......
......@@ -3,6 +3,7 @@ import { InputService } from '../classes/input-service';
import { TextAreaComponent } from 'common/components/ui-elements/text-area.component';
import { TextFieldComponent } from 'common/components/ui-elements/text-field.component';
import { SpellCorrectComponent } from 'common/components/ui-elements/spell-correct.component';
import { TextFieldSimpleComponent } from 'common/components/ui-elements/text-field-simple.component';
@Injectable({
providedIn: 'root'
......@@ -11,7 +12,7 @@ export class KeyboardService extends InputService {
alternativeKeyboardShowFrench!: boolean;
toggle(focusedElement: HTMLElement | null,
elementComponent: TextAreaComponent | TextFieldComponent | SpellCorrectComponent,
elementComponent: TextAreaComponent | TextFieldComponent | TextFieldSimpleComponent | SpellCorrectComponent,
isMobileWithoutHardwareKeyboard: boolean): boolean {
if (focusedElement && isMobileWithoutHardwareKeyboard) {
this.alternativeKeyboardShowFrench = elementComponent.elementModel.softwareKeyboardShowFrench;
......
......@@ -4,6 +4,7 @@ import { TextAreaComponent } from 'common/components/ui-elements/text-area.compo
import { InputAssistancePreset } from 'common/interfaces/elements';
import { InputService } from '../classes/input-service';
import { SpellCorrectComponent } from 'common/components/ui-elements/spell-correct.component';
import { TextFieldSimpleComponent } from 'common/components/ui-elements/text-field-simple.component';
@Injectable({
providedIn: 'root'
......@@ -13,7 +14,8 @@ export class KeypadService extends InputService {
position!: 'floating' | 'right';
toggle(focusedElement: HTMLElement | null,
elementComponent: TextAreaComponent | TextFieldComponent | SpellCorrectComponent): boolean {
elementComponent: TextAreaComponent | TextFieldComponent | TextFieldSimpleComponent | SpellCorrectComponent):
boolean {
if (focusedElement) {
this.preset = elementComponent.elementModel.inputAssistancePreset;
this.position = elementComponent.elementModel.inputAssistancePosition;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment