I am trying to simulate the pressing of the back b...
# compose
v
I am trying to simulate the pressing of the back button on android on desktop compose. How do I go about this task. It has been frustrating (to put it nicely) to make a usable desktop UI because everything is peachy for mobile but no thought was given to desktop users (mobile first development = plague)
šŸ™„ 1
a
You’ll need to be more specific about what you want to achieve.
v
Basically when a User presses the Back button on the mouse (mouse button 4 I believe) the application would work the same way as if the person press the back button on an android phone.
a
That entirely depends on your app. There’s no inherent ā€œback navigationā€ mechanism in desktop apps.
šŸ‘ 1
Like what would ā€œbackā€ do when editing a Word document?
In Android you have the concept of an activity and a navigation backstack. These don’t exist on the desktop.
šŸ‘† 2
v
great... so no useful stuff for desktop Guess ill just see if i can make a stack of screens in voyager and maintain it myself... compose lacking as always
z
The concept of generic ā€œnavigation backā€ is a core Android UX concept, it always has been. It’s never been on most common desktop OSes, as far as I’m aware. This has nothing to do with compose.
šŸ‘† 2
v
Except the fact there are very few " Desktop Exclusive" features, like hotkeys, navigation of any sort, or even onHover. Funny how for something like hovering, its all about this is a phone thing so nah but when its a phone feature, desktop does not have that so no. Double standard much?
z
I imagine your life would be so much better, it certainly would be here, if you were capable of expressing a single thought in a way that is not condescending and sarcastic.
šŸ˜‚ 6
šŸ‘ 3
šŸ‘šŸ¾ 1
v
Less sarcasm today, more dissapointment. Both with Mobile first in general and compose desktop specifically. It just seems that on android its all integrated while on desktop im running basically as if im on an android emulator (except the emulator would have a back stack šŸ˜‚).
a
I really think either you don’t understand something, or we don’t understand what you mean.
šŸ‘ 1
There is no such thing as a desktop ā€œbackā€ concept. Not in Compose, but in general on the desktop.
No major desktop UI toolkit has a built-in concept of ā€œbackā€.
v
TBH both me or u not understanding are extremely possible. Basically making a back button on my UI in a "comfortable" way would look bad and still not be great for desktop, now the normal way is not great for mobile but it looks good and they have the backstack. Now wouldnt it be great to have the back button on your mouse navigate between different UI pages? However I have to go third party for mouse listening, and because there is not back stack, I have to make one
a
If you’re looking for a non-standard feature that you want to borrow from another platform, then you will typically need to do it yourself, or find a 3rd party who did it. Nothing surprising about that.
v
My major issue is that the library keeps saying its a mobile library which is why features like hovering are not part of it, but then when I want to use a mobile feature, its not there because the desktop does not have that feature. It seems only one side is getting dedicated features, while the other side is getting a "port"
a
What library says that? Compose for desktop is a desktop library.
and it has hovering
and tooltips
and menubars
and windows, tray icons, mouse-wheel scrolling
But also yes - Google has way more people and resources dedicated to Jetpack Compose than JetBrains does to Compose for Desktop. So progress there is faster. But we do nevertheless provide a pretty good framework.
šŸ‘ 1
Nothing surprising or unfair there either
v
Oh jeezus ok I apolgize im a bad reader, my intellisense told me one thing and then i saw a bad post on discord probably should have serch b4 rant on that stuff. it is tangent to my issue but not great look. I know mouse scrolling was supportedd and windows/trayicons were too. I also know for a fact default windowbar customization is not supported but no one cares because the work arounds work fine. I dont think controls on the window preview work though right? I also believe the layout editor is not on desktop and running a desktop project is pretty annoying currently (seems thats a regression though so probably not the normal case). I also believe there is no way to do global listeners and from what I can see I think native context menu support not there?
a
Ask your questions one by one, in a constructive way, maybe in #compose-desktop and hopefully you’ll get an answer.
v
I swear we have way to many compose channels
But sure if those ever give me trouble ill ask (except the run problems, those I have asked and was never rsolved lol)
s
Compose doesn't have any concept of navigation (there is AndroidX Navigation for Compose, but that's a completely different library). You can use a multiplatform navigation library like Decompose that works with Compose and it has a concept of "back" in the way that I think that you mean it.
v
Yes I am using voyager
s
I've never used it. I would guess you should be looking into how they handle back presses and how you can listen for the button presses that you're expecting and pass them to your navigation system.
e
It took me approximately 5 minutes to set up handling back presses in compose desktop ĀÆ\_(惄)_/ĀÆ
😁 1
v
what did you do?
e
Honestly I'm debating whether or not I should tell you. I don't want to reward bad behavior.
šŸ˜‚ 4
no red 2
😐 1
a
With Decompose this would be a few lines of code on the Desktop App side.
v
Elizer, Be a dick then, cool with me. There is 0% chance I wont get this, just trying to bounce ideas
Arkadii so decompose has a method in place for this, thats good to know thanks
a
Yep, some people are using Esc key as back button: https://github.com/arkivanov/Decompose/discussions/512#discussioncomment-7388151 I think it all depends on the use case and application. May be fine for apps like kiosks, etc.
s
Agreed. Ashampoo Photos also uses ESC as the back button. More specifically using a redux pattern the Desktop app sends a
AppAction.Close
event while the Android back button dispatches the same event. Visible back buttons in the UI also do the same. So in business logic there is absolutely no difference if using the UI button or the ESC key.
šŸ‘ 1
Basically when a User presses the Back button on the mouse (mouse button 4 I believe)
Ashampoo Photos doesn’t recognize that. I’m not sure which event that even would send as my mouse has no back button. Not sure how many people actually use that. šŸ¤·ā€ā™‚ļø
k
At this point this is just inventing a thing that doesn’t exist on any of the desktop platforms that I’m familiar with. Which is the reason why there’s no place for it right now as a core Compose Desktop / multiplatform feature.
a
I think it depends on the application. I can imagine plenty of use cases. E.g. a car GUI with hardware buttons, a game menu UI, a kiosk with hardware buttons, etc.
Definitely less priority than most of the other things, but still. I think we'll have it automatically with the official first-party navigation solution. For (not only) now we can leverage third-party libs.
v
first party navigation solution?
that exists?
a
It is planned, I guess
164 Views