Move custom mouse event handler into MouseStateService
Don't need to keep it in CoreBrowserTerminal
This commit is contained in:
@@ -82,6 +82,8 @@ export class MockMouseStateService implements IMouseStateService {
|
||||
public consumeWheelEvent(ev: WheelEvent, cellHeight: number, dpr: number): number {
|
||||
return 1;
|
||||
}
|
||||
public setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void { }
|
||||
public allowCustomWheelEvent(ev: WheelEvent): boolean { return true; }
|
||||
}
|
||||
|
||||
export class MockCharsetService implements ICharsetService {
|
||||
|
||||
@@ -175,6 +175,7 @@ export class MouseStateService extends Disposable implements IMouseStateService
|
||||
private _activeEncoding: string = '';
|
||||
private _lastEvent: ICoreMouseEvent | null = null;
|
||||
private _wheelPartialScroll: number = 0;
|
||||
private _customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined;
|
||||
|
||||
private readonly _onProtocolChange = this._register(new Emitter<CoreMouseEventType>());
|
||||
public readonly onProtocolChange = this._onProtocolChange.event;
|
||||
@@ -268,6 +269,14 @@ export class MouseStateService extends Disposable implements IMouseStateService
|
||||
return amount;
|
||||
}
|
||||
|
||||
public setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void {
|
||||
this._customWheelEventHandler = customWheelEventHandler;
|
||||
}
|
||||
|
||||
public allowCustomWheelEvent(ev: WheelEvent): boolean {
|
||||
return this._customWheelEventHandler ? this._customWheelEventHandler(ev) !== false : true;
|
||||
}
|
||||
|
||||
private _applyScrollModifier(amount: number, ev: WheelEvent): number {
|
||||
// Multiply the scroll speed when the modifier key is pressed
|
||||
if (ev.altKey || ev.ctrlKey || ev.shiftKey) {
|
||||
|
||||
@@ -70,6 +70,16 @@ export interface IMouseStateService {
|
||||
* Process wheel event taking partial scroll into account.
|
||||
*/
|
||||
consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number;
|
||||
|
||||
/**
|
||||
* Sets a custom wheel event handler that can veto wheel processing.
|
||||
*/
|
||||
setCustomWheelEventHandler(customWheelEventHandler: ((event: WheelEvent) => boolean) | undefined): void;
|
||||
|
||||
/**
|
||||
* Checks whether a wheel event should be processed.
|
||||
*/
|
||||
allowCustomWheelEvent(ev: WheelEvent): boolean;
|
||||
}
|
||||
|
||||
export const ICoreService = createDecorator<ICoreService>('CoreService');
|
||||
|
||||
Reference in New Issue
Block a user