Set cursor (#505)
* implemented QCursor setter for QWidget::setCursor method * sorted includes, removed console.log statement from tests
This commit is contained in:
parent
0043c50f32
commit
300925260e
@ -6,6 +6,7 @@
|
||||
#include "QtCore/QObject/qobject_macro.h"
|
||||
#include "QtCore/QPoint/qpoint_wrap.h"
|
||||
#include "QtCore/QSize/qsize_wrap.h"
|
||||
#include "QtGui/QCursor/qcursor_wrap.h"
|
||||
#include "QtGui/QIcon/qicon_wrap.h"
|
||||
#include "QtWidgets/QAction/qaction_wrap.h"
|
||||
#include "QtWidgets/QLayout/qlayout_wrap.h"
|
||||
@ -117,9 +118,15 @@
|
||||
Napi::Value setCursor(const Napi::CallbackInfo& info) { \
|
||||
Napi::Env env = info.Env(); \
|
||||
Napi::HandleScope scope(env); \
|
||||
Napi::Number cursor = info[0].As<Napi::Number>(); \
|
||||
this->instance->setCursor( \
|
||||
static_cast<Qt::CursorShape>(cursor.Int32Value())); \
|
||||
if (info[0].IsNumber()) { \
|
||||
Napi::Number cursor = info[0].As<Napi::Number>(); \
|
||||
this->instance->setCursor( \
|
||||
static_cast<Qt::CursorShape>(cursor.Int32Value())); \
|
||||
} else { \
|
||||
Napi::Object obj = info[0].As<Napi::Object>(); \
|
||||
QCursorWrap* wrap = Napi::ObjectWrap<QCursorWrap>::Unwrap(obj); \
|
||||
this->instance->setCursor(*wrap->getInternalInstance()); \
|
||||
} \
|
||||
return env.Null(); \
|
||||
} \
|
||||
Napi::Value setWindowIcon(const Napi::CallbackInfo& info) { \
|
||||
|
||||
@ -136,7 +136,11 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> extends YogaWid
|
||||
}
|
||||
setCursor(cursor: CursorShape | QCursor): void {
|
||||
//TODO:getter
|
||||
this.native.setCursor(cursor);
|
||||
if (typeof cursor === 'number') {
|
||||
this.native.setCursor(cursor);
|
||||
} else {
|
||||
this.native.setCursor(cursor.native);
|
||||
}
|
||||
}
|
||||
setWindowIcon(icon: QIcon): void {
|
||||
//TODO:getter
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import { QWidget } from '../QWidget';
|
||||
import { CursorShape } from '../../QtEnums/CursorShape';
|
||||
import { QCursor } from '../../..';
|
||||
|
||||
describe('QWidget', () => {
|
||||
const view = new QWidget();
|
||||
@ -98,4 +100,9 @@ describe('QWidget', () => {
|
||||
expect(mock).toBeCalledWith('testName');
|
||||
expect(mock).toBeCalledTimes(1);
|
||||
});
|
||||
it('should accept QCursor as setCursor argument', () => {
|
||||
const widget = new QWidget();
|
||||
const cursor = new QCursor(CursorShape.BusyCursor);
|
||||
expect(() => widget.setCursor(cursor)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user