Just starting out? Need help? Post your questions and find answers here.
Dirk Geppert
 
Posts: 116
Joined: Fri Sep 22, 2017 7:02 am

Touchscreen and DisplayPopupMenu()

by Dirk Geppert Tue May 14, 2019 2:21 pm

Hi,

the manual says for DisplayPopupMenu(#Menu) : "Displays a PopupMenu under the current mouse position or at the given screen location".

On devices with no mouse, likes phones or Touchscreens in generell, the menu appears on top left (0, 0) of the Screen.
Is there a way to determine the coordinates of a TouchScreen tap? Then I could store and use it with OpenMenu...

Ciao dige
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: Touchscreen and DisplayPopupMenu()

by falsam Sat May 18, 2019 1:58 pm

Works with an Android terminal.
Code: Select all
Declare DisplayMenuPopUp()
Declare IsMobileDevice()

;Remove debug window
!$('div').eq(0).remove()

OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_Background)

If CreatePopupMenu(0)
  MenuItem(1, "item 1")
  MenuItem(2, "item 2")
  MenuItem(3, "etc ...")
EndIf

If IsMobileDevice()
  BindEvent(#PB_Event_LeftClick, @DisplayMenuPopUp())
Else
  BindEvent(#PB_Event_RightClick, @DisplayMenuPopUp())
EndIf

Procedure DisplayMenuPopUp()
  DisplayPopupMenu(0, WindowID(0))
EndProcedure

Procedure IsMobileDevice() 
  !if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
  !   return true;
  ! } else {
  !   return false;
  ! }
EndProcedure


Test with an apk ;)

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
falsam
 
Posts: 275
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: Touchscreen and DisplayPopupMenu()

by falsam Sat May 18, 2019 2:06 pm

I could have used DeviceInfo(#PB_Device_Platform) to determine if I am on a mobile terminal ....

➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

Sorry for my poor english
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 3 guests