tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[bug] `window.set_cursor_visible(false)` does not work.

Open ILikeTeaALot opened this issue 1 year ago • 4 comments

Describe the bug

When creating a window, and running window.set_cursor_visible(false), the cursor should be hidden when the window opens. It isn't.

Reproduction

during setup, run the following:

tauri::Builder::default()
    // ... initial tauri context builder calls
    app.setup(|app| {
        let window = app.get_webview_window("main").unwrap();
        // Cursor
        window.set_cursor_visible(false)?;
    })
    // ... rest of tauri init
    .run(tauri::generate_context!())

Expected behavior

The cursor should be hidden/invisible.

Full tauri info output

`cargo tauri info`

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 126.0.2592.87
    ✔ MSVC: 
        - Visual Studio Community 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.13.1
    - yarn: 1.22.15
    - npm: 10.5.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.23      
    - tauri-build [RUST]: 2.0.0-beta.18
    - wry [RUST]: 0.41.0
    - tao [RUST]: 0.28.1
    - tauri-cli [RUST]: 2.0.0-beta.17  
    - @tauri-apps/api [NPM]: 2.0.0-beta.14
    - @tauri-apps/cli [NPM]: 2.0.0-beta.17

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

N/A - Not a crash

Additional context

Setting the CSS cursor: none; property works, but requires user interaction to take effect.

(to help this come up if someone else searches for it: the method set_cursor_visible on window is not working)

ILikeTeaALot avatar Jul 09 '24 15:07 ILikeTeaALot

I am having this same issue in Tauri 1.7.0.

brooke-ec avatar Jul 20 '24 11:07 brooke-ec

Same issue invoking this from JS:

import { appWindow } from '@tauri-apps/api/window'
appWindow
  .setCursorVisible(false)
  .then(() => {
    console.log('mouse hidden') // this gets printed
  })
  .catch((err) => {
    console.error(err)
  })

with

"@tauri-apps/api": "^1.6.0",
"@tauri-apps/cli": "^1.6.1",

and this tauri.conf.json:

        "allowlist": {
           "all": true,
           "window": {
               "all": true
           }
       },

davcri avatar Oct 08 '24 10:10 davcri

I'm having the same issue in

"@tauri-apps/api": "^2"

With following code

import { Window } from '@tauri-apps/api/window'

Window.getByLabel('main').then((window) => {
  if (window) {
    window.setCursorVisible(false)
  }
})

Beelink avatar Jan 18 '25 13:01 Beelink

Still broken from JS on 2.9.3

oscarfsbs avatar Nov 19 '25 23:11 oscarfsbs