![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | JymWythawhy |
![]() |
Old Version | Published before Godot 3 was released. |
I have a grid of tiles that change sprite textures when clicked on (Black or white for marked or not marked). I am trying to get it to the point where if you then drag the clicked mouse over other tiles, they will also change. The code is like this:
export (Texture) var Blank
export (Texture) var Filled
var filled = false
func _on_Tile_input_event( ev ):
if(ev.type==InputEvent.Mouse_Button and ev.pressed):
if (ev.button_index==BUTTON_LEFT):
if(filled)
get_node("Sprite").set_texture(Blank)
filled = false
else:
get_node("Sprite").set_texture(Filled)
filled = true
func _on_Tile_mouse_enter():
if Input.is_mouse_button_pressed(BUTTON_LEFT):
if(filled)
get_node("Sprite").set_texture(Blank)
filled = false
else:
get_node("Sprite").set_texture(Filled)
filled = true
If I click outside of any tiles and then drag onto tiles, they will fill in as the mouse goes over them, just like I expect. If I click on a single tile, that one will change, just as I expect. However, if I click on a tile and then drag, only that first tile will change, and the _on_Tile_mouse_enter
function will not be called. Its like the _on_Tile_input_event
function has captured the event system and won’t allow anything else through until I release the mouse button. Is there a way to tell it it can go on its way after registering the mouse down, and no need to wait around for the mouse up?
You should put a print() statement at the front of these enter events to confirm that.
avencherus | 2016-11-21 21:42
Great idea- When I do so, I see what I described above as well. If I am not clicking on a tile first, every time I mouse over a tile I see my print statement, as expected. But if I have clicked on a tile first and drag away from it, no print statements are made for the mouse overs. Its like it can’t handle other mouse inputs until I let up the mouse.
JymWythawhy | 2016-11-22 01:14
What’s that code look like? I haven’t been able to reproduce what you’re describing.
avencherus | 2016-11-22 01:19
Here is a minimal example I created that exhibits the problem. GitHub - JymWythawhy/MinimalExample: A minimal example of a problem I encountered in Godot
JymWythawhy | 2016-11-22 02:32
Took a look. That does seem unusual. There was a brief discussion here, but I didn’t really see anything else: mouse_enter signal doesn't fire if lmb is held down · Issue #6362 · godotengine/godot · GitHub
avencherus | 2016-11-22 03:05