You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@roerohan, Assigning an ID (taking it from the props) for the canvas helps capture a screen shot by using the canvas.toDataURL(type, encoderOptions); browser API
You could use the rfb object that's exposed with the onConnect method:
functionApp(){constvncRfb=useRef(null);constvncScreenRef=useRef<React.ElementRef<typeofVncScreen>>(null);useEffect(()=>{// Assuming that `canvasId` is definedvncRfb.current?._canvas?.id=canvasId;},[vncRfb.current]);return(<VncScreenurl={vncUrl}scaleViewportdebugref={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 canvasId prop in the library - unless you can tell me if there are any issues with this approach, or if assigning it in the library is better in any way.
Activity
roerohan commentedon Feb 26, 2022
Hello @candiedoperation
The
canvaselement is inserted by theRFBobject in the noVNC library itself, I do not create a canvas on my own. Here's what I do:react-vnc/src/lib/VncScreen.tsx
Lines 252 to 258 in 932cb06
And then, the screen reference is passed to the
RFBconstructor:react-vnc/src/lib/VncScreen.tsx
Line 183 in 932cb06
Now, there are 2 ways to resolve your issue:
canvasIdprop, and set:rfbobject that's exposed with theonConnectmethod:I think you could use the second approach here, I'm not really in favor of adding a
canvasIdprop in the library - unless you can tell me if there are any issues with this approach, or if assigning it in the library is better in any way.roerohan commentedon Feb 26, 2022
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.