Recent

Author Topic: [SOLVED] LAMW: jMenu submenu - direct command  (Read 3006 times)

tk

  • Sr. Member
  • ****
  • Posts: 361
[SOLVED] LAMW: jMenu submenu - direct command
« on: November 17, 2016, 02:46:41 pm »
Hi jmpessoa,
sorry to pest, having another trouble, this time with jMenu.

Want to achieve following behavior:
1. there appears a menu (at the bottom of the phone display) when user presses the device menu button.
2. from this menu when user clicks on the item directly a custom dialog appears (jCustomDialog).

Now I have (basically a copy paste from jMenu demo):

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.AndroidModule1CreateOptionMenu(Sender: TObject;
  2.   jObjMenu: jObject);
  3. var
  4.    I: Integer;
  5.    SubMenu: jObject;
  6. begin
  7.    for I := 0 to MainMenu.Options.Count - 1 do
  8.    begin
  9.      SubMenu := MainMenu.AddSubMenu(jObjMenu, MainMenu.Options[I], MainMenu.IconIdentifiers[I]);
  10.      MainMenu.AddItem(SubMenu, I + 1, MainMenu.Options[I], mitDefault);
  11.    end;
  12. end;
  13.  
  14. procedure TAndroidModule1.AndroidModule1ClickOptionMenuItem(Sender: TObject;
  15.   jObjMenuItem: jObject; itemID: integer; itemCaption: string; checked: boolean
  16.   );
  17. begin
  18.   case itemID of
  19.     1:
  20.     begin
  21.       EDDlg.Text := FIP;
  22.       Dlg.Show('Select IP address:');
  23.     end;
  24.     2:
  25.     begin
  26.       EDDlg.Text := FPort;
  27.       Dlg.Show('Select UPD port:');
  28.     end;
  29.   end;
  30. end;    
  31.  
  32. // Dlg: jCustomDialog;  EDDlg: jEditText;
  33.  

But this produces intermediate 'submenu' in the middle of the phone display and I must click the item there once again.
Is there a way how to remove this intermediate 'submenu'?

Thank you
« Last Edit: November 20, 2016, 11:29:49 am by tk »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: LAMW: jMenu submenu - direct command
« Reply #1 on: November 20, 2016, 03:37:16 am »

Hi tk!

Please, Try:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.DataModuleCreateOptionMenu(Sender: TObject; jObjMenu: jObject);
  2. var
  3.    i: integer;
  4. begin
  5.    for i:=0 to jMenu1.Options.Count-1 do   //options and IconIdentifiers added in design time
  6.    begin
  7.         jMenu1.AddItem(jObjMenu, 10+i {itemID}, jMenu1.Options.Strings[i], jMenu1.IconIdentifiers.Strings[i] {..res/drawable-xxx}, mitDefault, misIfRoomWithText {or misNever});
  8.    end;
  9. end;
  10.  

NOTE:
1. if  "misIfRoomWithText" then firsts 3 options will be    
exhibit in action bar and others will be handle by hard button menu

2. if  "misNever" then all options will be handle by hard button menu ...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tk

  • Sr. Member
  • ****
  • Posts: 361
Re: LAMW: jMenu submenu - direct command
« Reply #2 on: November 20, 2016, 11:29:34 am »
2. if  "misNever" then all options will be handle by hard button menu ...

Exactly what I needed, thank you!

 

TinyPortal © 2005-2018