Skip to content

Commit

Permalink
Expose all MouseTarget properties
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Aug 21, 2018
1 parent 57f2743 commit 1d3c0f7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 23 additions & 1 deletion packages/editor/src/browser/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,30 @@ export enum MouseTargetType {
}

export interface MouseTarget {
readonly position: Position;
/**
* The target element
*/
readonly element: Element;
/**
* The target type
*/
readonly type: MouseTargetType;
/**
* The 'approximate' editor position
*/
readonly position: Position;
/**
* Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line).
*/
readonly mouseColumn: number;
/**
* The 'approximate' editor range
*/
readonly range: Range;
/**
* Some extra detail.
*/
readonly detail: any;
}

export interface EditorMouseEvent {
Expand Down
5 changes: 4 additions & 1 deletion packages/monaco/src/browser/monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class MonacoEditor implements TextEditor, IEditorReference {
this.onCursorPositionChangedEmitter,
this.onSelectionChangedEmitter,
this.onFocusChangedEmitter,
this.onDocumentContentChangedEmitter
this.onDocumentContentChangedEmitter,
this.onMouseDownEmitter
]);
this.documents.add(document);
this.autoSizing = options && options.autoSizing !== undefined ? options.autoSizing : false;
Expand Down Expand Up @@ -124,6 +125,8 @@ export class MonacoEditor implements TextEditor, IEditorReference {
const event = {
target: {
...e.target,
mouseColumn: this.m2p.asPosition(undefined, e.target.mouseColumn).character,
range: this.m2p.asRange(e.target.range),
position: this.m2p.asPosition(lineNumber, column),
},
event: e.event.browserEvent
Expand Down

0 comments on commit 1d3c0f7

Please sign in to comment.