@dark-engine/platform-desktop
Version:
Dark renderer to desktop platforms like Windows, Linux, macOS via Nodegui and Qt
35 lines (34 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.QDarkPlainTextEdit = exports.PlainTextEdit = void 0;
const nodegui_1 = require('@nodegui/nodegui');
const core_1 = require('@dark-engine/core');
const factory_1 = require('../factory');
const PlainTextEdit = (0, core_1.component)(
props => {
const { ref, onTextChanged } = props;
const rootRef = (0, core_1.useRef)(null);
(0, core_1.useImperativeHandle)(ref, () => ({ node: rootRef.current }));
(0, core_1.useLayoutEffect)(() => {
const { current } = rootRef;
const handler = () => {
(0, core_1.detectIsFunction)(onTextChanged) && onTextChanged(current.toPlainText());
};
current.addEventListener('textChanged', handler);
return () => current.removeEventListener('textChanged', handler);
}, []);
return (0, factory_1.qPlainTextEdit)({ ref: rootRef, ...props });
},
{ displayName: 'PlainTextEdit' },
);
exports.PlainTextEdit = PlainTextEdit;
class QDarkPlainTextEdit extends nodegui_1.QPlainTextEdit {
setText(value) {
this.setPlainText(value);
}
setPlaceholder(value) {
this.setPlaceholderText(value);
}
}
exports.QDarkPlainTextEdit = QDarkPlainTextEdit;
//# sourceMappingURL=plain-text-edit.js.map