March 29, 2024, 07:01:05 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Responding to list box using Oncontrol

Started by AdrianFox, November 13, 2011, 01:27:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AdrianFox

Glad the site is back up.  Yesterday was the first time I've tried to access it for ages so it was 'sod's law' it was unavailable due to the server error!   :)
I just wonder why with a listbox, when I want to respond to a highlighted item, using ONCONTROL  I seem only able to use a double click (@IDLBUTTONDBLCLK) calling a sub (checking
if @notifycode=@idlbuttondbclk) rather than a single click.
I'd like to use a simple single click @idlbuttondn.  I can do that if I make use of the 'normal' main window handler routine but if I want to avoid having a main handler entirely I can't.
Is there any way I can get a response to the highlighted item in the list box with a single click, while still making use of ONCONTROL rather than the window's main handler routine?

Any thoughts would be welcome.

Outline here....
window win
openwindow win,0,0,900,502,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU|@MAXIMIZED,0,"Seed Lists",NULL
CONTROL win,@EDIT,"",15,16,640,70,@cteditleft|@cteditmulti|@vscroll,editbox_1
CONTROL win,@LISTBOX,"",15,96,640,400,@CTLISTSTANDARD|@CTLISTNOTIFY|@CTLISTTABS|@VSCROLL,COMBO_1

oncontrol win,combo_1,@IDLBUTTONDBLCLK,&checkcomboDOUBLEclick  'THIS WORKS

'BELOW DOESN'T WORK..

oncontrol win,combo_1,@IDLBUTTONDN,&checkcomboSINGLEclick
waituntil win=0

sub checkcomboDOUBLEclick    'THIS WORKS
if @notifycode=@IDLBUTTONDBLCLK
setcontroltext win,editbox_1,"Item double clicked"
endif
return 0
endsub

sub checkcomboSINGLEclick    'THIS WON'T WORK
if @notifycode=@IDLBUTTONDN
setcontroltext win,editbox_1,"Item single clicked"
endif
return 0
endsub
Adrian Fox

zaphod

Hello,
maybe like that :



window win
openwindow win,0,0,900,502,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU|@MAXIMIZED,0,"Seed Lists",NULL
CONTROL win,@EDIT,"",15,16,640,70,@cteditleft|@cteditmulti|@vscroll,editbox_1
CONTROL win,@LISTBOX,"",15,96,640,400,@CTLISTSTANDARD|@CTLISTNOTIFY|@CTLISTTABS|@VSCROLL,COMBO_1

oncontrol win,combo_1,@IDLBUTTONDBLCLK,&checkcomboDOUBLEclick  'THIS WORKS

'BELOW DOESN'T WORK..

''''oncontrol win,combo_1,@IDLBUTTONDN,&checkcomboSINGLEclick
oncontrol d1,4,@LBNSELCHANGE,&checkcomboSINGLEclick

waituntil win=0

sub checkcomboDOUBLEclick    'THIS WORKS
if @notifycode=@IDLBUTTONDBLCLK
setcontroltext win,editbox_1,"Item double clicked"
endif
return 0
endsub

sub checkcomboSINGLEclick    'THIS WON'T WORK
''''if @notifycode=@IDLBUTTONDN
if @notifycode=@LBNSELCHANGE
setcontroltext win,editbox_1,"Item single clicked"
endif
return 0
endsub


aurelCB

Adrian you use wrong @notifycode,try this:
window win
INT editbox_1,COMBO_1
editbox_1=1
COMBO_1=2
openwindow win,0,0,900,502,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@SYSMENU|@MAXIMIZED,0,"Seed Lists",&main
CONTROL win,@EDIT,"",15,16,640,70,@cteditleft|@cteditmulti|@vscroll,editbox_1
CONTROL win,@LISTBOX,"",15,96,640,400,@CTLISTSTANDARD|@CTLISTNOTIFY|@CTLISTTABS|@VSCROLL,COMBO_1
ADDSTRING win,combo_1,"one"
ADDSTRING win,combo_1,"two"
ADDSTRING win,combo_1,"three"
ADDSTRING win,combo_1,"four"
'oncontrol win,combo_1,@IDLBUTTONDBLCLK,&checkcomboDOUBLEclick  'THIS WORKS

'BELOW work WORK.. because selection is changed
oncontrol win,COMBO_1,@CBNSELCHANGE,&checkcomboSINGLEclick

waituntil win=0
end

/*sub checkcomboDOUBLEclick    'THIS WORKS
if @notifycode=@IDLBUTTONDBLCLK
setcontroltext win,editbox_1,"Item double clicked"
endif
return 0
endsub */
SUB main
SELECT @MESSAGE
case @IDCLOSEWINDOW
closewindow win
ENDSELECT
ENDSUB

sub checkcomboSINGLEclick    'THIS WON'T WORK

MESSAGEBOX 0,"Item single clicked","OK"

return
endsub

AdrianFox

 :)  Thanks to both.... @CBNSELCHANGE is what I needed and that works fine for the single click.   I should have looked at all the notification messages in the user guide!

Merci a tous,

Adrian Fox