change(web): titlebar configEnabled, helpEnabled

This commit is contained in:
Joshua A. Horton 2022-10-20 10:12:21 +07:00
parent 9301626dd2
commit a7e01f9172
3 changed files with 41 additions and 1 deletions

View file

@ -161,7 +161,7 @@ namespace com.keyman.osk.layouts {
let newWidth = this.startWidth + cumulativeX;
let newHeight = this.startHeight + cumulativeY;
// Set the smallest and largest OSK size
if(newWidth < 0.2*screen.width) {
newWidth = 0.2*screen.width;

View file

@ -10,11 +10,37 @@ namespace com.keyman.osk.layouts {
private _configButton: HTMLDivElement;
private _caption: HTMLSpanElement;
private _helpEnabled: boolean;
private _configEnabled: boolean;
public get helpEnabled(): boolean {
return this._helpEnabled;
}
public set helpEnabled(val) {
this._helpEnabled = val;
this._helpButton.style.visibility = val ? 'visible' : 'hidden';
}
public get configEnabled(): boolean {
return this._configEnabled;
}
public set configEnabled(val) {
this._configEnabled = val;
this._configButton.style.visibility = val ? 'visible' : 'hidden';
}
private static readonly DISPLAY_HEIGHT = ParsedLengthStyle.inPixels(20); // As set in kmwosk.css
public constructor(dragHandler?: MouseDragOperation) {
this._element = this.buildTitleBar();
this.helpEnabled = false;
this.configEnabled = false;
if(dragHandler) {
this.element.onmousedown = dragHandler.mouseDownHandler;
}

View file

@ -1078,6 +1078,20 @@ namespace com.keyman.osk {
* Description Wrapper function to add and identify OSK-specific event handlers
*/
['addEventListener'](event: string, func: (obj) => boolean) {
// As the following title bar buttons (for desktop / FloatingOSKView) do nothing unless
// a site designer uses these events, we disable / hide them until an event is attached.
let titleBar = this.headerView;
if(titleBar && titleBar instanceof layouts.TitleBar) {
switch(event) {
case 'configclick':
titleBar.configEnabled = true;
break;
case 'helpclick':
titleBar.helpEnabled = true;
break;
}
}
return com.keyman.singleton.util.addEventListener('osk.'+event, func);
}
}