Board.KolibriOS.org

Official KolibriOS board
It is currently Thu Jul 02, 2020 2:24 pm

All times are UTC+03:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed May 20, 2020 5:34 pm 
Offline
Designer
User avatar

Joined: Thu Jan 25, 2007 3:33 pm
Posts: 5283
Няшное меню /SYS/DEVELOP/MENU
Attachment:
lmenu.png
lmenu.png [ 5.05 KiB | Viewed 847 times ]

Для запуска делаем функцию:
Code:
#define MENU_ALIGN_TOP_LEFT  0
#define MENU_ALIGN_TOP_RIGHT 1
#define MENU_ALIGN_BOT_LEFT  2
#define MENU_ALIGN_BOT_RIGHT 3

:dword shared_mem = NULL;
:char shared_name[] = "LMENU";
void open_lmenu(dword _x, _y, _position, _selected, _text1)
{
   if (!shared_mem) {
      shared_mem = memopen(#shared_name, 16, SHM_CREATE + SHM_WRITE);
      if (EDX) shared_mem = memopen(#shared_name, 16, SHM_WRITE);
   }
   ESDWORD[shared_mem     ] = _selected;
   ESDWORD[shared_mem +  4] = _x;
   ESDWORD[shared_mem +  8] = _y;
   ESDWORD[shared_mem + 12] = _position;
   menu_process_id = RunProgram("/sys/develop/menu", _text1);
}
Вызываем так
Code:
open_lmenu(Form.left+mouse.x+5, Form.top+mouse.y+skin_height, MENU_ALIGN_TOP_RIGHT, 1, "Пункт1\nПункт2");
либо так
Code:
open_lmenu(Form.left + mouse.x+4, Form.top + skin_height + mouse.y,MENU_ALIGN_TOP_LEFT, NULL, #folder_actions);

char folder_actions[]=
"Open        |Enter
-
Copy         |Crl+C
Cut          |Crl+X
Paste        |Crl+V
-
Delete       |Del
Properties   |F8";
Получаем нажатый пункт меню
Code:
:dword get_menu_click()
{
   if (menu_process_id) && (GetProcessSlot(menu_process_id)) {
      return NULL;
   } else {
      menu_process_id = NULL;
      EAX = ESDWORD[shared_mem];
      ESDWORD[shared_mem] = 0;
      return EAX;      
   }
}
Если есть идеи по улучшению кода/подхода - пишите.

_________________
Звиздеть не мешки ворочать


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+03:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited