sugarlabs / sugar

Sugar GTK shell
GNU General Public License v3.0
255 stars 241 forks source link

Home view long touch displays menu in unusual location #825

Closed quozl closed 7 months ago

quozl commented 5 years ago

In the home view, a long touch on an activity displays the menu in the top left of the screen. The menu should be displayed near the finger press.

vaishnavi192 commented 7 months ago

is this issue open. Can I work on it ? @quozl

chimosky commented 7 months ago

@vaishnavi192 the issue is still open as it's not been closed, you should checkout our contributing guide which has this;

Please note there is no need to ask permission to work on an issue. You should check for pull requests linked to an issue you are addressing; if there are none, then assume nobody has done anything. Begin to fix the problem, test, make your commits, push your commits, then make a pull request. Mention an issue number in the pull request, but not the commit message. These practices allow the competition of ideas (Sugar Labs is a meritocracy.

vaishnavi192 commented 7 months ago

Hey @quozl @chimosky I wanted some help for solving this issue. I found out that GDK doesn't provide a built-in way to detect long press events. So we can achieve this in other way by implementing x and y co-ordinates. Here is a rough example I will make changes in view.py file Screenshot from 2024-02-03 18-13-39

import time

def _touch_event_cb(self, widget, event): if event.type == Gdk.EventType.TOUCH_BEGIN: self.touch_start_time = GLib.get_monotonic_time() elif event.type == Gdk.EventType.TOUCH_END: if self.touch_start_time is not None: elapsed_time = (GLib.get_monotonic_time() - self.touch_start_time) / 1000000
if elapsed_time > 1.0: # 1.0 seconds for a long press self.show_menu(event) self.touch_start_time = None def show_menu(self, event):

using event.x and event.y to position the menu near the finger press

    print("Long press detected at", event.x, event.y)

I am not sure if this is the correct way? can you plz guide me further?

chimosky commented 7 months ago

Hey @quozl @chimosky I wanted some help for solving this issue. I found out that GDK doesn't provide a built-in way to detect long press events. So we can achieve this in other way by implementing x and y co-ordinates. Here is a rough example I will make changes in view.py file

Have you been able to reproduce the issue, as I just tried and the issue no longer persists.

Gdk does provide ways to handle long press events, just depends on what exactly you want to achieve.

For future purposes, please share texts instead of screenshots, you can also use ticks to enclose code to make it more readable on GH.

If you're interested, the GH writing and formatting syntax would come-in handy.