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

Support for SetCustomCursor in Krom #2872

Open
PHandradee opened this issue May 6, 2023 · 2 comments
Open

Support for SetCustomCursor in Krom #2872

PHandradee opened this issue May 6, 2023 · 2 comments
Labels
feature request This issue requests a feature kha This issue needs to be fixed/implemented in Kha

Comments

@PHandradee
Copy link

PHandradee commented May 6, 2023

Krom dont supports change the cursor via kha.input.Mouse.setSystemCursor().

It was nice to have this possibility.

`package arm;

import kha.Image;

class MouseCursorHandler extends iron.Trait {

var current_mouse = kha.input.Mouse.get();
var custom_mouse_image: Image;

public function new() {
	super();

	notifyOnInit(OnInit);

}

function OnInit() {
	iron.data.Data.getImage("DefaultCursor.png", (image: Image) -> {
		custom_mouse_image = image;

		current_mouse.setSystemCursor(kha.input.Mouse.MouseCursor.Custom(custom_mouse_image));

	});
}

}
`
With this code above the mouse cursor is changed when exporting to Web, but in Krom this don't work.

@PHandradee PHandradee added the feature request This issue requests a feature label May 6, 2023
@rpaladin
Copy link
Contributor

rpaladin commented May 6, 2023

Hi. I had the same question and @ MoritzBrueckner gave me a working solution, although it requires some manual source tweaking.

RPaladin — Kha related, but people who use Kha claim that this code works fine in Kha but it doesn't for me in Armory - it also doesn't throw any errors for me so they may be well right. Why doesn't this code work in Armory it seems?
kha.input.Mouse.get().setSystemCursor(Crosshair);

Reference: https://github.com/Kode/Kha/blob/main/Sources/kha/input/Mouse.hx#L12-L28

timodriaan — Do you use Krom? The code looks correct to me, will try to reproduce it now (or do you already have a small example file)?
RPaladin —
  1. I'm using Krom Player (Armory).

  2. Using a default blend with no cache.

The cursor stays the same "Default" icon/image.

timodriaan — Also doesn't work for me, will investigate. It definitely worked before (~ 1 1/2 years ago when I worked on my game jam game), but Armory's Krom.hx needed to be modified back then, perhaps it's a similar issue...

Even sillier, it's not implemented in Kha's Krom backend

timodriaan — It's only implemented in Armorcore, which is too bad because any change made to Kha would be overwritten when Lubos updates Kha. It's the same problem as always 😄

I will write it in the Kha discord server, for now you need to add static function setMouseCursor(id: Int): Void; to <sdk>/Kha/Backends/Krom/Krom.hx and then call Krom.setMouseCursor(cursorValue) in your Haxe code #if kha_krom where cursorValue is an integer representing the cursor you want (Kha's implementation uses an enum so you can't just use the enum values). It's really messy 😄

Discord message ID, if you're interested: https://discord.com/channels/486771218599510021/486773417316450305/1053045903293939722

@MoritzBrueckner in reference to asking Rob, were you able to get something implemented for Kha?

@MoritzBrueckner
Copy link
Collaborator

@MoritzBrueckner in reference to asking Rob, were you able to get something implemented for Kha?

I sadly don't remember this anymore (I don't even remember anymore whether I even asked), but there are essentially two issues here:

  1. Kha supports changing the mouse cursor and Armory's version of Krom does as well, but these functionalities currently aren't implemented in the Krom backend of Kha (that's what my Discord message above was about). However, I think the Kode/Krom version doesn't allow to change the mouse cursor at the moment, so this needs to be implemented first before we can implement it in Kha (otherwise Rob wouldn't merge it and we can't PR to Armory's version of Kha, as explained above).
  2. Kinc doesn't support custom cursor images (contrary to a predefined set of system cursor images), but there is a Kha API for it. This is what is done in the code example above. I opened a feature request on the Kinc repository for it: Add support for custom mouse cursor images Kode/Kinc#798.

@MoritzBrueckner MoritzBrueckner added the kha This issue needs to be fixed/implemented in Kha label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request This issue requests a feature kha This issue needs to be fixed/implemented in Kha
Projects
None yet
Development

No branches or pull requests

3 participants