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