Screenshot Feature #30
-
|
@roerohan, Assigning an ID (taking it from the props) for the canvas helps capture a screen shot by using the This would be a really useful feature. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hello @candiedoperation The react-vnc/src/lib/VncScreen.tsx Lines 252 to 258 in 932cb06 And then, the screen reference is passed to the react-vnc/src/lib/VncScreen.tsx Line 183 in 932cb06 Now, there are 2 ways to resolve your issue:
_rfb._canvas.id = canvasId;
function App() {
const vncRfb = useRef(null);
const vncScreenRef = useRef<React.ElementRef<typeof VncScreen>>(null);
useEffect(() => {
// Assuming that `canvasId` is defined
vncRfb.current?._canvas?.id = canvasId;
}, [vncRfb.current]);
return (
<VncScreen
url={vncUrl}
scaleViewport
debug
ref={vncScreenRef}
onConnect={(rfb) => {
console.log('connected', rfb);
vncRfb.current = rfb;
}}
/>
)
}I think you could use the second approach here, I'm not really in favor of adding a |
Beta Was this translation helpful? Give feedback.
-
|
In #26, I've exposed the function App() {
const vncScreenRef = useRef<React.ElementRef<typeof VncScreen>>(null);
return (
<VncScreen
url={vncUrl}
scaleViewport
debug
ref={vncScreenRef}
/>
)
}You can access the You can now use |
Beta Was this translation helpful? Give feedback.
In #26, I've exposed the
rfbobject. So, if you have a code snippet like:You can access the
rfbobject usingvncScreenRef.current?.rfb. If therfbobject isn't set, it's value isnull.You can now use
vncScreenRef?.rfb?._canvas.id = canvasId;