Re: wxEVT_COMMAND_LISTBOX_DOUBLECLICKED

new topic     » goto parent     » topic index » view thread      » older message » newer message

I know I hate it when users do this to me, but...oh, I forgot to mention --
I'm using a multi-column list control (wxListCtrl).  Is there a way to
capture the double-click event from a list ctrl, as in the following
example?
Thanks in advance,
Gnu-B

without warning

include wxEuphoria.e
include wxButton.e
include wxList.e
include wxGraphics.e

constant

 WinFrame   = create( wxFrame, {0, -1, "List", -1, -1, 400, 220} ),
 Win = create( wxPanel, {WinFrame}),
 List1 = create( wxListCtrl, {Win, -1, 10, 10, 320, 140} ),
 Button1 = create( wxButton, {Win, -1, "Info...",10, 150, 60, 32} )

procedure init()
atom Void

Void = insert_list_column( List1, 1, "English", wxLEFT, 120 )
Void = insert_list_column( List1, 1, "Espanol", wxLEFT, 120 )

Void = insert_listctrl_item( List1, 0, {"one","uno"}, -1 )
Void = insert_listctrl_item( List1, 0, {"two","dos"}, -1 )
Void = insert_listctrl_item( List1, 0, {"three","tres"}, -1 )
Void = insert_listctrl_item( List1, 0, {"four","quatro"}, -1 )

end procedure

init()

procedure Click_Button1(atom this, atom event_type, atom id, atom event)
 object index, result, string
 index = get_selection( List1 )
 if length(index) = 0 then
  return
 end if
 string = get_string_selection( List1 )

 result = message_box(
  sprintf( "Selected Item Index = %d \n", index ) &
  sprintf( "Selected Item Text = %s ",
   string ),
  "List Information", 0 )
end procedure
set_event_handler( List1, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
routine_id( "Click_Button1" ) )
set_event_handler(Button1, get_id(Button1), wxEVT_COMMAND_BUTTON_CLICKED,
routine_id( "Click_Button1" ))

 wxMain( WinFrame )



                                                                           
             Matt Lewis                                                    
             <guest@RapidEupho                                             
             ria.com>                                                   To 
                                       EUforum at topica.com                  
             02/09/2006 07:19                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re:                                 
             Please respond to         wxEVT_COMMAND_LISTBOX_DOUBLECLICKED 
             EUforum at topica.co                                             
                     m                                                     
                                                                           
                                                                           
                                                                           
                                                                           






posted by: Matt Lewis <matthewwalkerlewis at gmail.com>

Brian K. Clark wrote:
>
>
> Thanks Matt for all of your help so far, and sorry to be a PITA, but (no
> pun intended)... Has the wxWidgets event
> wxEVT_COMMAND_LISTBOX_DOUBLECLICKED been implemented in wxEuphoria?  I
> tried:
>
> set_event_handler(itemsList, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
> routine_id( "show_item" ))
>
> which doesn't cause a runtime error, but also doesn't fire the proc.
>

It works for me.  See the example below:
without warning

include wxEuphoria.e
include wxButton.e
include wxList.e
include wxGraphics.e

constant

 WinFrame   = create( wxFrame, {0, -1, "List", -1, -1, 200, 220} ),
 Win = create( wxPanel, {WinFrame}),
 List1 = create( wxListBox, {Win, -1, 10, 10, 120, 140} ),
 Button1 = create( wxButton, {Win, -1, "Info...", 10, 150, 60, 32} )

procedure WinFrame_Activate( atom this, atom event_type, atom id, atom
event )

 add_item( List1, {"one", "two", "three", "four", "five",
  "six", "seven", "eight", "nine","ten"} )
end procedure
set_event_handler( WinFrame, -1, wxEVT_ACTIVATE,
routine_id("WinFrame_Activate"))


procedure Click_Button1(atom this, atom event_type, atom id, atom event)
 integer count, index
 object result, string

 -- get index
 index = get_selection( List1 )
 if index = -1 then
  return
 end if
 count = list_count( List1 )
 string = get_string_selection( List1 )

 result = message_box(
  sprintf( "List Count = %d \n", {count } ) &
  sprintf( "Selected Item Index = %d \n", { index } ) &
  sprintf( "Selected Item Text = %s ",
   { string} ),
  "List Information", 0 )
end procedure
set_event_handler( List1, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
routine_id( "Click_Button1" ) )
set_event_handler(Button1, get_id(Button1), wxEVT_COMMAND_BUTTON_CLICKED,
routine_id( "Click_Button1" ))

wxMain( WinFrame )


Matt Lewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu