Hiding the mouse cursor (DEF-1619)

after years of this topic, what is the easy way to hide mouse cursor now?!

I have downloaded this example, i still see mouse cursor in game(windows 10)
edit:
i have one error:
ERROR:GAMESYS: Error running Window callback: /main/cursor.script:5: attempt to call field ā€˜enable_mouse_cursorā€™ (a nil value)

You should add DefOS.
Also its api has changed.

defos.set_cursor_visible(bool_value)
4 Likes

Thanks selimanac, does it workson html5 too?

I donā€™t know, I didnā€™t try it with DefOS.
You can simple hide cursor by using css+js on html page for canvas without defos. But hiding cursor on html canvas pretty weird to me.

1 Like

Iā€™m enjoying developing in Defold and I understand that it leans more towards a framework than a game engine but even love2d framework has a built-in,

love.mouse.setVisible(false)

This is such a basic requirement, using plugin for it feels like an overkill!

1 Like

Funny that you just replied to thisā€¦I read this post yesterday and was disappointed to find out I have to use an add-on. Plus when itā€™s a built-in the documentation can be consistent and easily found.

Maybe if they had approved add-ons that they referenced in their documentation and even put them in the engine for ease of adding them it would be better. And it would clue people in on where to get this functionality.

1 Like

Yes, we have the intention to add things like this but it is dependant on finishing the GLFW3 update for linux, which is already in flight. I hope we can get the new functions in before christmas.

2 Likes

Most of the time, every developer believes that a particular feature they need for their game should be part of the engine. However, if the engine were to include every feature that each individual developer considers a ā€œmust-have,ā€ it would become bloated, with a large size and 90% of features unused by most individual games.

You may argue, ā€œNo, not all of them, only this oneā€”itā€™s so obvious.ā€ To that, I would respond: Iā€™ve heard this argument countless times about thousands of different features. Thatā€™s why extensions exist.

4 Likes

I am totally onboard with keeping the engine minimalist, avoiding bloat and using plugins.

However thereā€™s a risk of minimalism descending into austerity and that might give a perception that using Defold has too many friction points compared to other similar frameworks like love2d.

As users who love Defold it is our responsibility to point out friction points and gaps, then leave it to the wisdom of the Defold team to fill those gaps.

Recent reply by @jhonny.goransson gives hope to those who would like this feature built-in.

Iā€™m not opposed to this particular feature, and itā€™s likely that it will be implemented in the engine. Iā€™m simply trying to explain the reasoning behind it.
The frictions you mentioned are the cost of other benefits, such as speed, small size, fewer breaking changes, etc.

Not exactly sure what the difference is here, but yes we are pretty strict with this approach. If thereā€™re is enough users/benefit to be included in the default functionality, we do it.
If it can be done by the user in Lua or via an extension, then we do that.
So itā€™s not a whole process, but fairly strict guidelines.

Right now though when I try to use DEFOS it gives me this error. I have to delete that folder and then run it everytime.

image

And this is using the sample project as Iā€™m trying to learn this. I get that error as well in my project. To me this add-in is a lot different then all the others and bit more complicated to get working.

Hereā€™s a video of it.
https://youtu.be/0QDH0edOr2Y

Also how do we get rid of these build errors when using defos? Right now this type of add-in isnā€™t very clean to me. Iā€™m not a c++ coder so Iā€™m a bit lost when using this one. It doesnā€™t work like any other add-in Iā€™m using. It appears defos. doesnā€™t work like any other methods in the engine.

/example/example.gui_script
	Line 14: Global variable in lowercase initial, Did you miss `local` or misspell it?
	Line 14: setting non-standard global variable 'toggle_cursor_lock'
	Line 16: Undefined global `defos`.
	Line 16: accessing undefined variable 'defos'
	Line 21: Global variable in lowercase initial, Did you miss `local` or misspell it?
	Line 21: setting non-standard global variable 'extract_to_savefolder'
	Line 28: Need check nil.
	Line 29: Need check nil.
	Line 30: Need check nil.
	Line 36: unused variable 'appname'
	Line 37: Undefined global `defos`.
	Line 37: accessing undefined variable 'defos'
	Line 37: Undefined global `defos`.
	Line 37: accessing undefined variable 'defos'
	Line 41: Undefined global `defos`.
	Line 41: accessing undefined variable 'defos'
	Line 42: Undefined global `defos`.
	Line 42: accessing undefined variable 'defos'
	Line 43: Undefined global `defos`.
	Line 43: accessing undefined variable 'defos'
	Line 44: Undefined global `defos`.
	Line 44: accessing undefined variable 'defos'
	Line 50: Undefined global `defos`.
	Line 50: accessing undefined variable 'defos'
	Line 50: accessing undefined variable 'extract_to_savefolder'
	Line 56: Undefined global `defos`.
	Line 56: accessing undefined variable 'defos'
	Line 56: accessing undefined variable 'extract_to_savefolder'
	Line 61: Undefined global `defos`.
	Line 61: accessing undefined variable 'defos'
	Line 69: Undefined global `defos`.
	Line 69: accessing undefined variable 'defos'
	Line 72: Undefined global `defos`.
	Line 72: accessing undefined variable 'defos'
	Line 75: Undefined global `defos`.
	Line 75: accessing undefined variable 'defos'
	Line 79: Undefined global `defos`.
	Line 79: accessing undefined variable 'defos'
	Line 82: Undefined global `defos`.
	Line 82: accessing undefined variable 'defos'
	Line 87: Undefined global `defos`.
	Line 87: accessing undefined variable 'defos'
	Line 90: accessing undefined variable 'toggle_cursor_lock'
	Line 93: Undefined global `defos`.
	Line 93: accessing undefined variable 'defos'
	Line 96: Undefined global `defos`.
	Line 96: accessing undefined variable 'defos'
	Line 101: Undefined global `defos`.
	Line 101: accessing undefined variable 'defos'
	Line 113: Undefined global `defos`.
	Line 113: accessing undefined variable 'defos'
	Line 113: Undefined global `defos`.
	Line 113: accessing undefined variable 'defos'
	Line 116: Undefined global `defos`.
	Line 116: accessing undefined variable 'defos'
	Line 122: Undefined global `defos`.
	Line 122: accessing undefined variable 'defos'
	Line 125: Undefined global `defos`.
	Line 125: accessing undefined variable 'defos'
	Line 136: Undefined global `defos`.
	Line 136: accessing undefined variable 'defos'
	Line 149: Undefined global `defos`.
	Line 149: accessing undefined variable 'defos'
	Line 151: Undefined global `defos`.
	Line 151: accessing undefined variable 'defos'
	Line 153: Undefined global `defos`.
	Line 153: accessing undefined variable 'defos'
	Line 154: Undefined global `defos`.
	Line 154: accessing undefined variable 'defos'
	Line 156: Undefined global `defos`.
	Line 156: accessing undefined variable 'defos'
	Line 157: Undefined global `defos`.
	Line 157: accessing undefined variable 'defos'
	Line 158: Undefined global `defos`.
	Line 158: accessing undefined variable 'defos'
	Line 159: Undefined global `defos`.
	Line 159: accessing undefined variable 'defos'
	Line 162: Global variable in lowercase initial, Did you miss `local` or misspell it?
	Line 162: setting non-standard global variable 'update_clipping_label'
	Line 164: Global variable in lowercase initial, Did you miss `local` or misspell it?
	Line 164: setting non-standard global variable 'text'
	Line 166: Global variable in lowercase initial, Did you miss `local` or misspell it?
	Line 166: setting non-standard global variable 'text'
	Line 169: accessing undefined variable 'text'
	Line 176: Undefined global `defos`.
	Line 176: accessing undefined variable 'defos'
	Line 180: Undefined global `defos`.
	Line 180: accessing undefined variable 'defos'
	Line 184: Undefined global `defos`.
	Line 184: accessing undefined variable 'defos'
	Line 188: Undefined global `defos`.
	Line 188: accessing undefined variable 'defos'
	Line 192: Undefined global `defos`.
	Line 192: accessing undefined variable 'defos'
	Line 196: Undefined global `defos`.
	Line 196: accessing undefined variable 'defos'
	Line 201: Undefined global `defos`.
	Line 201: accessing undefined variable 'defos'
	Line 207: Undefined global `defos`.
	Line 207: accessing undefined variable 'defos'
	Line 212: Undefined global `defos`.
	Line 212: accessing undefined variable 'defos'
	Line 218: Undefined global `defos`.
	Line 218: accessing undefined variable 'defos'
	Line 226: Undefined global `defos`.
	Line 226: accessing undefined variable 'defos'
	Line 231: Undefined global `defos`.
	Line 231: accessing undefined variable 'defos'
	Line 232: accessing undefined variable 'update_clipping_label'
	Line 237: accessing undefined variable 'toggle_cursor_lock'
	Line 242: Undefined global `defos`.
	Line 242: accessing undefined variable 'defos'
	Line 242: Undefined global `defos`.
	Line 242: accessing undefined variable 'defos'
	Line 242: Undefined global `defos`.
	Line 242: accessing undefined variable 'defos'
	Line 247: Undefined global `defos`.
	Line 247: accessing undefined variable 'defos'
	Line 258: Undefined global `defos`.
	Line 258: accessing undefined variable 'defos'

I can confirm defos is causing the error or at least is involved in the error.

If I remove defos (and then restart defold) this behavior stops occurring.

This thread is not related to Defos. I highly suggest posting Defos-related topics in its own dedicated thread.

These are not errors, nor are they warnings related to Defos. Tthey come from the Lua Language Server used by the Defold Editor. It canā€™t find the global defos since it is not a defined Lua global variable in the project.

1 Like

As a workaround window.set_mouse_lock() works for my case.

2 Likes