Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ILikeTeaALot opened this issue Jul 9, 2024 · 3 comments
Open

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

ILikeTeaALot opened this issue Jul 9, 2024 · 3 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@ILikeTeaALot
Copy link

ILikeTeaALot commented Jul 9, 2024

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 ILikeTeaALot added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jul 9, 2024
@brooke-ec
Copy link

I am having this same issue in Tauri 1.7.0.

@davcri
Copy link

davcri commented Oct 8, 2024

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
           }
       },

@Beelink
Copy link

Beelink commented Jan 18, 2025

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 Beelink mentioned this issue Jan 18, 2025
25 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

4 participants