Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Sending touch events to multiple widgets
-
I've tried to use a TextView on a layer below to display some text but I also want to be able to scroll through it. However, to dismiss the keyboard, I've put a transparent custom view, that receives touches and dismissed the keyboard. If I do it this way, the scrolls are blocked, but if I remove that view, I can't dismiss the keyboard. Any ideas on what can be done here?
-
@Leva7 , have a look at View.touch_enabled
Keeping in mind the ui objects are also views -
So... you want to be able to tap the textview to dismiss the view? or tap anywhere else?
If you want to tap elsewhere, you can either put a giant ui.Button under your textview, or use a custom view with touch_began. -
@Phuket2, I can't configure them properly to disable the touches. You see, when the keyboard is up, I also want to be able to scroll. It's just the matter of differentiating the scroll from a simple tap. I tried messing around with delegates, it didn't quite help
-
@JonB, Yea, I've tried smth like this, it works but only outside said TextView. It's blocking the touch events as it is above the ui.Button. This wouldn't be such a problem if that TextView wouldn't take up pretty much the entire screen space. I'd like to be able to tap on the TextView to dismiss as well
-
@Leva7 , can you post the code here so we can see
-
-
@Leva7 , sorry. I will have to get back to you. I am having big problems with json files. Small and large
-
@Phuket2, It's okay, I wish I could help you but I have no experience with json :)
-
@Leva7 , thanks.my experience is also limited. I am really not sure what has gone wrong. But one hint is that I tried to install ujson, a c implementation of json. It failed as I expected it too. But maybe it's screwed up some things. Can't see a install folder. But even small json text now my ipad crashes. I got your pyui code. Put trying to paste it into the Pythonista editor , just crashes it every time. But have been having other problems with small json files. So I need to track it down.
Thanks anyway -
This is the ui picture, excuse the lines, 5-sec draw in paint. I have an iPod so the screen was quite small, that's why i didn't screenshot the editor. So the txMain view is what displays the text. The way I've got my code set right now is that the scrolls are passing but the keyboard can't be dismissed. The lines represent a transparent view that should receive single taps, but is turned off. Right now I also have a huge button behind all of that to dismiss the keyboard. That's about it.
P.S. By "no experience with json" I mean like NO experience xD -
@Leva7 , sorry heading to sleep very soon. I am on GMT +7 so almost 1:30 am here. But will look more tomorrow, well today 😱
-
is the txtMain supposed to be editable?
if not, set touch_enabled=False, which lets the touch go through to the component underneath.though this might only work in current beta.
Alternatively, you might consider adding a dismiss button to the keyboard. Someone recently had an objc example on how to do this.
-
@Leva7 , if you get a chance, could you please copy from the link you supplied for the py ui file and try pasting it into a empty editor sheet, and see if it crashes 😁 Best to exit and renter Pythonista first to make sure you don't lose anything. That google link was hard for me to extract the text out of also. If you have Dropbox , that would be better or Github or even a gist. If you rename a xxx.pyui file to .json you will see the json data. When you change the ext back to pyui it is back in the ui designer
-
If you just need a TextView to present text and be scrollable without being editable, setting editable = False is enough, without the need of any additional layers.
Or was the use case more complicated?
-
Okay, I managed to find a solution. When I was talking about delegates, I mostly looked into the did_begin/did_end methods, neglecting the should_begin method. Implementing a dismission in that method and returning False did the job. About some of the suggestions:
Yes, I've had the editable property set to False, but pressing on the view didn't do anything.
If I would have set touch_enabled to False, the scrolling wouldn't function.
Thanks for all the help!
Now I don't know if I should create a separate post but I have another question. I'm trying to somehow implement autoscrolling when that textview gets updated. I've put the autoscrolling into the function where I update the txMain contents, but every time it does update, the scroll position automatically goes to the top, resulting in some kind of a bounce (to the top, then to the bottom again). Is there a better way to implement autoscroll?