https://kotlinlang.org logo
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
benchmarks
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
confetti
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hiring-french
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
lincheck
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by
Title
n

nfrankel

01/08/2021, 5:09 AM
still trying to wrap my head around compose for desktop i still have two concerns mainly related to the fact that it’s an port from an android framework • is there any table component? the best i could do was to use a
SwingPanel
to use the faithful
JTable
• how do you bind the tab key to jump to another field?
g

gildor

01/08/2021, 6:28 AM
You can use LazyVerticalGrid for this: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyVerticalGrid(android[…]lues,%20kotlin.Function1) It’s not exactly table. I think there is no table yet, but you can probably implement using custom layout (shouldn’t be hard for simple cases)
👍 1
x

xetra11

01/08/2021, 7:19 AM
@nfrankel same issue and had to use a custom table as well. But that is simply cause I have no idea of JTable etc. I think I will replace my implementation with JTable
👍 2
Until Components has it's own stuff
Compose
n

nfrankel

01/08/2021, 7:27 AM
JTable
is legacy but the effort to use it is pretty low compared to a custom implementation
x

xetra11

01/08/2021, 7:34 AM
@nfrankel what do you mean by legacy? Is there something newer from Swing? If not I think it's state of the art in terms of Java UI 😛 ?
n

nfrankel

01/08/2021, 7:38 AM
come on, there’s java fx
:java: 1
g

gildor

01/08/2021, 7:58 AM
There are plans for Java FX support in compose, as I remember
😮 1
👍 2
x

xetra11

01/08/2021, 8:11 AM
@nfrankel ah JavaFX is newer than the Swing stuff. Never did Java UI things so that certainly is a new information for me 😄
j

jim

01/08/2021, 12:08 PM
Obviously do whatever you need to do to make your app work, swing interoperability exists as an escape hatch for exactly that reason. But know that if you're able to use only composable functions, you will be able to avoid the impedance-mismatch complexities associated with crossing framework boundaries. For this reason, I'd strongly encourage you try using only composable functions (especially for layout widgets) if you're able. If someone wanted to try implementing a table view in Compose, it shouldn't be too hard and it sounds like it might be popular as there appears to be an appetite within this channel.
👍 2
l

Logan Knight

01/08/2021, 12:59 PM
@jim I read this thread being interested in the tab question. Do you have any thoughts on that? I thought I would give it a go and see if I could figure it. The following responds to keyboard events nicely, but is silent when 'tab' is pressed.
TextField(
    modifier = Modifier.onKeyEvent {
        println(it)
        false
    },
)
j

jim

01/08/2021, 1:21 PM
@Logan Knight Have you looked at
focusModifier
? I think it might do what you want, rather than trying to write your own. Although
focusModifier
does use
onKeyEvent
so I'm not sure if that'll get you any further since my best guess/assumption would be that
TextField
is perhaps consuming the tab input? cc @Ralston Da Silva who knows more about this than I do since he wrote the focus navigation stuff IIRC. cc @Siyamed for text field related question. One of them may know more.
l

Logan Knight

01/08/2021, 1:24 PM
I have not, I will play around with it and see what I can learn. Thank you!
n

nfrankel

01/08/2021, 1:26 PM
please share when you have an updated @Logan Knight 🙂
👍 1
d

Dominaezzz

01/08/2021, 2:57 PM
There used to be a
DataTable
component, now it's gone. If you can find it and copy it, it'll give you a head start.
n

nfrankel

01/08/2021, 3:16 PM
thanks @Dominaezzz this is about learning by doing but i’m too lazy to learn that much 😅
l

Logan Knight

01/08/2021, 6:43 PM
@jim @nfrankel It seems this is has yet to be implemented as far as I can tell. The Swing Focus Subsystem has a traversal key concept that is able to be manipulated and configured. It's default behavior is:
The focus subsystem consumes focus traversal keys, such as Tab and Shift Tab. If you need to prevent the focus traversal keys from being consumed, you can call

component.setFocusTraversalKeysEnabled(false)

on the component that is firing the key events. Your program must then handle focus traversal on its own. Alternatively, you can use the KeyEventDispatcher class to pre-listen to all key events. The focus page has detailed information on the focus subsystem
Ref: https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html You can disable the behavior for each component. It seems that it would need to be configured in the
ComposeLayer.Wrapper
which is not exposed as part of the public API and is the KeyEvent source, Then some Compose native implementation would have to manage it since Compose does not use Swing
Components
accept at the top. You can capture tab key strokes with:
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher {
    println(it)
    true
}
But that's of little use except on a global level. At least those are my thoughts.
I assume this will be or is on the road map?
n

nfrankel

01/08/2021, 6:45 PM
thanks @Logan Knight i think that’s a good subject of work as tab’bing to the next field is one of the most important feature in desktop guis
l

Logan Knight

01/08/2021, 6:46 PM
I agree.
j

jim

01/08/2021, 6:51 PM
Sounds right to me, I'll add it to the todo list. Would anyone be interested in helping out with keyboard navigation? Contributions welcomed!
🎉 3
l

Logan Knight

01/08/2021, 8:50 PM
I'd be open to it but am not familiar enough with Kotlin or Compose yet to feel that I could. Let me mull it over and familiarize myself more. If/when I feel I could be of help, I'll PM you and see if the work still needs to be done.
s

Siyamed

01/08/2021, 8:57 PM
This is something we need in compose (not only desktop), the line between mobile and desktop is a very vague one, especially nowadays
r

Ralston Da Silva

01/13/2021, 9:20 PM
Sorry for the late response, but yes, This is on our roadmap. Focus navigation is still a work in progress. Right now focus modifiers use a keyEvent modifier to intercept tab, shift+tab and the arrow keys and move focus if a custom focus order is specified. You can see an example here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]/java/androidx/compose/ui/demos/focus/CustomFocusOrderDemo.kt Ultimately, you will be able to move focus even if you don't specify a custom focus order.
l

Logan Knight

01/14/2021, 6:07 PM
@Ralston Da Silva Thank you for this