Is it possible to highlight and copy text while using OrbitControls?

As I work on my Three.js project with OrbitControls.js, I've come across an issue where I am unable to select or highlight any text using OrbitControls.

For example, you can try visiting this link: (try selecting the text "orbit control example" at the top of the page, it's not possible)

Does anyone know how to enable text selection while using OrbitControl?

(Do I need to disable the control every time I want to copy text?)

Thank you.

Answer №1

If you want to change the default behavior of OrbitControls in listening to mouse events on the entire document, causing conflicts with other functionalities like selecting text or opening context menus, you can specify a specific DOM node as the second argument when constructing THREE.OrbitControls. This way, OrbitControls will only listen to mouse events on this designated DOM node.

For instance, if your code looks like this:

var renderer = …;
container.appendChild(renderer.domElement);
…
var controls = new THREE.OrbitControls(camera);

You can modify the last line to be:

var controls = new THREE.OrbitControls(camera, renderer.domElement);

In the example mentioned, you should move the initialization of controls:

controls = new THREE.OrbitControls( camera );
controls.addEventListener( 'change', render );

To after initializing renderer, and include renderer.domElement as the second argument in the constructor THREE.OrbitControls. This adjustment allows you to freely select text on the page without interference.

Answer №2

Generate the new input field:

let identityInput = document.createElement('INPUT');

Enhance the click functionality by setting focus on the newly created element:

identityInput.addEventListener('click', function(event) {
    $(this).focus();
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ensure that the Promise is resolved upon the event firing, without the need for multiple event

I'm currently working on a solution where I need to handle promise resolution when an EventEmitter event occurs. In the function containing this logic, an argument is passed and added to a stack. Later, items are processed from the stack with differe ...

What steps should be taken in order to trigger an action when scrolling to the content or when the content becomes

My webpage is filled with numerous images, and I am looking to implement some JavaScript and PHP functionalities when a user scrolls down to view each image. Here is my proposed solution: $(window).scroll(function(){ hT = $('.Picture-1A:eq(3)&apo ...

.css files standing their ground against modifications

Currently, I'm utilizing the WebStorm IDE to work on my React project. My goal is to make modifications to the app.css files in order to update the design. However, each time I attempt to build or run the project, it dismisses all of the changes I&apo ...

Adjust the stroke and fill colors of an SVG element when hovering over it

I am facing a challenge with an SVG image that I have: https://i.stack.imgur.com/r4XaX.png When hovered over or clicked, it should change to https://i.stack.imgur.com/EHRG2.png Current Icon <svg width="24" height="24" viewBox="0 0 24 24" fill="non ...

watchify with gulp requires two saves to update modifications

For a while now, I've been experimenting with watchify and encountering a saving issue. It appears that every time I make a change, I have to save twice for the modifications to reflect in the output. If I add new code to any JavaScript file, the ch ...

Issue with integrating React, Material UI, Typescript, Webpack, and server-side rendering (SSR

I encountered an issue with my server-side rendered app when I tried to integrate Material UI into it. Here is how my directory structure looks: app/ build/ * This directory is generated by webpack server_bundle.js public/ ...

Steps to insert a Drop-Down Sub-Menu

I'm just about finished with my navigation panel. Any tips on how to add a sub-menu? I currently have one in the Product page. Below is the HTML code containing the sub-menus: <nav> <ul> <li><a href="">HOME</a>&l ...

Change the content of an ion-card in Ionic2 dynamically

After fetching a list of books from the backend API provider, I am presented with sample data that looks like this: { "success":true, "books":[ { "id":1000, "book_code":"CC219102", "read_status":"completed", ...

Trouble in Jest: Async test error

I encountered a specific error message that reads: Cannot read property 'indexOf' of undefined at Function.isPendingSpecException After some investigation, I pinpointed the problem to this particular line of code: TokenRepositor ...

Insert a datum into an existing element

I need to modify a link by removing the title attribute and instead placing the title text in a data attribute called data-title. I want to achieve this using jquery. Can someone please provide guidance on how to do this? The goal is to remove the title e ...

Creating a dynamic table in HTML using PHP

I seem to be facing an issue with my PHP code. Below is the snippet of the code I am working with: <?php $s=(" SELECT * FROM my_tbl"); $W=mysql_query($s); ?> <table> <tr> <td> <center><s ...

Error: The number of format specifications in 'msgid' and 'msgstr' does not match. One fatal error was found by msgfmt

I encountered an error with Django-Admin that reads: "Execution of msgfmt failed: /home/djuka/project_app/locale/eng/LC_MESSAGES/django.po:49: number of format specifications in 'msgid' and 'msgstr' does not match. Msgfmt found 1 fatal ...

What is the process for rendering a page in node express from a route.post method?

My webpage fetches 100 memes from an API and displays them in a table. Each meme has a details button that should take the user to a specific page for that meme. However, even though my POST request to the meme route is successful, the meme details page is ...

"Troubleshooting ng-submit in AngularJS: How to Fix a Function That

I've encountered an issue with my angular-promise where a http method is not being called when a form is submitted using ng-submit. There are no errors, but it seems like the function is never executed. Here's the JavaScript code snippet: myapp. ...

What is the process of programmatically pinning a website to the Windows taskbar using JavaScript?

Is it feasible to pin a website without using the drag and drop method? I looked into the jQuery Pinify plugin, but from what I gathered, it only prompts users to pin websites through intelligent popups rather than automating the process itself. Can this ...

Associate information with HTML elements

I've come across this question multiple times, but the solutions are mostly focused on HTML5. My DOCTYPE declaration is: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I'm looking t ...

The @Input() function is failing to display or fetch the latest value that was passed

I am currently working on an angular project, and I've encountered a situation where I'm attempting to send a value from a parent component to a child component using the @Input() decorator. Despite my efforts, the child component continues to di ...

What is the best way to integrate NodeJS into a Java application?

I am currently developing a Java library, specifically, a Clojure library that runs on the JVM. In the process, I need to incorporate JavaScript execution. I initially attempted using Nashorn, but encountered limitations that may be too challenging to over ...

Is there a way to keep this table fixed in place as the user scrolls?

Is there an alternative way to fix the content on the header so that it remains visible on the screen until the next table, even when scrolling? I've tried using position: sticky and top: 0, but the header still scrolls past. I have checked for any ov ...

Solving the right-to-left orientation issue in the Bootstrap navbar

I have implemented a navbar using the code below, which aligns well from the right side. However, the menu items are sorted in ltr order and I need them to be in rtl order, so that "Dropdown 1" starts from the right side of the page. Currently, it appears ...