https://kotlinlang.org logo
#korge
Title
# korge
k

kirillrakhman

06/03/2020, 8:35 PM
Are click handlers on text supported? I've tried
Copy code
class MenuScene : Scene() {
    override suspend fun Container.sceneInit() {
        text("Play") {
            onClick {
                println("Changing to Game scene")
                sceneContainer.changeTo<GameScene>()
            }
        }
    }
}
but the event never triggers.
👀 1
d

Deactivated User

06/03/2020, 8:48 PM
If it doesn’t work, that’s definitely a bug. In the meantime you can create a
solidRect(width, height, Colors.TRANSPARENT_BLACK)
and put the event there Are you rendering the text using a BitmapFont?
k

kirillrakhman

06/03/2020, 8:48 PM
for now I'm using whatever is the default
d

Deactivated User

06/03/2020, 8:48 PM
If you press F7 or F12 it should display a debug overlay displaying clickable areas
does it show anything?
k

kirillrakhman

06/03/2020, 8:49 PM
message has been deleted
d

Deactivated User

06/03/2020, 8:50 PM
that red rectangle is the text clickable area (misplaced) or do you have another view there?
k

kirillrakhman

06/03/2020, 8:50 PM
let me clean up the scene
d

Deactivated User

06/03/2020, 8:51 PM
still, going to check, maybe the bounds are not computed correctly for text. Since we are using buttonText that already included an image in the background maybe we missed the bounds for text. Going to check and to create a regression test
k

kirillrakhman

06/03/2020, 8:51 PM
Copy code
class MenuScene : Scene() {
    override suspend fun Container.sceneInit() {

            text("Play", color = Colors.WHITE) {
                x = 200.0
                y= 200.0

                onClick {
                    println("Changing to Game scene")
                    sceneContainer.changeTo<GameScene>()
                }
            }
    }
}
that's the whole scene
it seems
Text
doesn't override
hitTest
when I do the solidRect, the text becomes invisible
d

Deactivated User

06/03/2020, 8:56 PM
Okay. I’ll fill a bug and will fix it
k

kirillrakhman

06/03/2020, 9:09 PM
@Deactivated User any tips on the invisible solidRect?
d

Deactivated User

06/03/2020, 9:15 PM
uhm how do you place the solidRect?
so I can reproduce it?
I’m checking this right now so I hope to have a fix for the issue in an hour or so
k

kirillrakhman

06/03/2020, 9:22 PM
OK, no hurry
Just
solidRect { text() }
With the color set to transparent black
d

Deactivated User

06/03/2020, 9:35 PM
Oh I see. That’s confusing. SolidRect shouldn’t be a container (legacy stuff that should be removed on KorGE 2.0). What you can do is:
Copy code
container {
   solidRect(100, 20, Colors.TRANSPARENT_BLACK)
   text("hello")
   onClick { ... }
}
https://github.com/korlibs/korge/pull/184 <-- will be available in the next version
👍 1
2 Views