Improve docs for QInputMethodQueryEvent; extract nativeObjectFromVariantType()
This commit is contained in:
parent
5879ad7ec4
commit
e9ff6a93fb
@ -36,3 +36,14 @@ export class QVariant extends Component {
|
||||
return this.native.toStringList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct native object which should be passed down to the
|
||||
* C++ wrapper from a QVariantType object.
|
||||
*/
|
||||
export function nativeObjectFromVariantType(obj: QVariantType): any {
|
||||
if (obj instanceof QRect) {
|
||||
return obj.native;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
import addon from '../../utils/addon';
|
||||
import { NativeRawPointer } from '../../core/Component';
|
||||
import { QVariant, QVariantType } from '../../QtCore/QVariant';
|
||||
import { QVariant, QVariantType, nativeObjectFromVariantType } from '../../QtCore/QVariant';
|
||||
import { QEvent } from './QEvent';
|
||||
import { QRect } from '../../QtCore/QRect';
|
||||
|
||||
/**
|
||||
* Note: Qt performs some default processing for `QInputMethodQueryEvents`.
|
||||
* When attaching an event listener via `addEventListener()` use the
|
||||
* options object to specify that you want to run after the default
|
||||
* processing, otherwise your `setValue()` calls will be overwritten.
|
||||
*/
|
||||
export class QInputMethodQueryEvent extends QEvent {
|
||||
constructor(event: NativeRawPointer<'QEvent'>) {
|
||||
super(new addon.QInputMethodQueryEvent(event));
|
||||
@ -14,11 +19,7 @@ export class QInputMethodQueryEvent extends QEvent {
|
||||
}
|
||||
|
||||
setValue(query: number /* InputMethodQuery */, value: QVariantType): void {
|
||||
if (value instanceof QRect) {
|
||||
this.native.setValue(query, value.native);
|
||||
} else {
|
||||
this.native.setValue(query, value);
|
||||
}
|
||||
this.native.setValue(query, nativeObjectFromVariantType(value));
|
||||
}
|
||||
|
||||
value(query: number /* InputMethodQuery */): QVariant {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user