Recent

Author Topic: Problems with context menu  (Read 614 times)

tango13

  • New Member
  • *
  • Posts: 30
Problems with context menu
« on: June 04, 2021, 05:51:45 pm »
Hi all,

I am trying to create a context menu but I don't seem to get it right, nothing shows up.

The create procedure is very simple to start with, I just copied it from the menu demo

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1CreateContextMenu(Sender: TObject;
  2.   jObjMenu: jObject);
  3. begin
  4.     if jObjMenu<>nil then
  5.     begin
  6.       jContextMenu1.SetHeader(jObjMenu, 'Context Menu!', '');
  7.       jContextMenu1.AddItem(jObjMenu, 10, 'Item 1', mitDefault);
  8.       jContextMenu1.AddItem(jObjMenu, 20, 'Item 2', mitDefault);
  9.       debugln('context menu created');
  10.     end;
  11.     debugln('context menu not created');
  12. end;

I added the two debugln statements but I don't see any of them anywhere in the log, as if the event is never fired.
What am I doing wrong?

Thank you!

jmpessoa

  • Hero Member
  • *****
  • Posts: 1920
Re: Problems with context menu
« Reply #1 on: June 04, 2021, 06:24:27 pm »
Quote
I just copied it from the menu demo...

Maybe you need link/bind the code in Object Inspector (form event properties)...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tango13

  • New Member
  • *
  • Posts: 30
Re: Problems with context menu
« Reply #2 on: June 05, 2021, 07:41:27 am »
Sorry, I forgot to mention that I already linked the procedures (create and click) to the respective form events OnCreateContextMenu and OnClickContextMenuItem, but still I don't get any sign of the code being executed.
Thank you.
« Last Edit: June 05, 2021, 07:46:37 am by tango13 »

tango13

  • New Member
  • *
  • Posts: 30
Re: Problems with context menu
« Reply #3 on: June 05, 2021, 08:11:08 am »
It seems like I cannot register a jdrawingview object for context menu, if I register a jbutton object it works.
Is that correct?

 

TinyPortal © 2005-2018