Assigning fixed variables ("data") via signal for items of a menu dynamically built



Hi there,

For some reasons I must build a menu and sub-menus dynamically via a loop.
My problem is how to "assign" a "fixed" value to the (g)pointer ("data")
parameter in order to handle click after ?

Here is a bunch of my (Pascal) code :
    For J:=1 to 3 do
    begin
      if J=1 then my_menu_subitems[J] := gtk_menu_item_new_with_label('item
1');
      if J=2 then my_menu_subitems[J] := gtk_menu_item_new_with_label('item
2');
      if J=3 then my_menu_subitems[J] := gtk_menu_item_new_with_label('item
3');
      gtk_menu_shell_append(GTK_MENU_SHELL(Common_Sub_Menu_For_Channels),
my_menu_subitems[J]);
      gtk_widget_show(my_menu_subitems[J]);    
     
g_signal_connect(G_OBJECT(my_menu_subitems[J]),'activate',G_CALLBACK(@Interface_Direct_Access_Actions),
PChar(inttostr((J)))); 
    ...
    
For instance I would like data=1 (ie PChar(inttostr((J)) ) was passed when
clicked on 1st item, data=2 for 2nd etc...
The problem is that the J value seems taken when clicking (and not at the
assigning moment) so it is always the highest value (of the loop) which is
sent (here 3).
How to handle this please ?

Thanks.
TomG
-- 
View this message in context: http://www.nabble.com/Assigning-fixed-variables-%28%22data%22%29-via-signal-for-items-of-a-menu-dynamically-built-tp18889349p18889349.html
Sent from the Gtk+ - General mailing list archive at Nabble.com.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]