Author |
Topic: Events (Read 592 times) |
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Events
« Thread started on: Nov 6th, 2015, 12:39am » |
|
I guess I'm dense ... or perhaps I should have paid for the Microsoft manuals.
I haven't found a list of events to write handlers for.
Certainly this isn't something traditionally handed down amongst generations of programmers. Perhaps it comes with the "tea" at some annual convention of Windows guys and gals.
I jest, but why isn't this a prominent list in at least one tutorial? Perhaps I'm just dense.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Events
« Reply #1 on: Nov 6th, 2015, 02:11am » |
|
on Nov 6th, 2015, 12:39am, pnlawrence wrote:I haven't found a list of events to write handlers for. |
|
I can't say I've ever seen a comprehensive list either, but searching for handler in the LBB help viewer allowed me to compile this:
Code:BMPBUTTON #window[.ext], bmpfile$, handler, anchor, posx, posy
BUTTON #window[.ext], "text", handler, anchor, xpos, ypos [, width, height]
CHECKBOX #window[.ext], "Caption", sethandler, resethandler, xpos, ypos, width, height
COMBOBOX #window[.ext], array$(), handler, xpos, ypos, width, height
LISTBOX #window.ext, array$(), handler, xpos, ypos, width, height
MENU #handle, "title", "text", handler {, "text", handler}
ONCOMERROR [handler]
POPUPMENU "text", handler {, "text", handler}
RADIOBUTTON #handle.ext, "label", sethandler, resethandler, xpos, ypos, width, height
SPRITETRAVELXY sprite x y speed handler (sprites)
TIMER milliseconds, handler | 0
TRAPCLOSE handler (any window)
WHEN event handler (graphicbox or graphics window) From the LB 4.5.0 docs the WHEN events are:
Code:WHEN leftButtonDown
WHEN leftButtonUp
WHEN leftButtonMove
WHEN leftButtonDouble
WHEN rightButtonDown
WHEN rightButtonUp
WHEN rightButtonMove
WHEN rightButtonDouble
WHEN middleButtonDown
WHEN middleButtonUp
WHEN middleButtonMove
WHEN middleButtonDouble
WHEN mouseMove
WHEN characterInput If I've missed any I'm sure somebody will point it out.
Richard.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: Events
« Reply #2 on: Nov 6th, 2015, 10:35am » |
|
You second example is what I'm wanting. The following is from the LB help file:
Quote:Controls and Events
The commands to create a controls must specify event handlers that are associated with user actions made on those controls (clicking, double-clicking, selecting, etc.). |
|
I don't see how I can create handlers for "user actions" if I don't know what the "user actions" are that the control is capable of returning.
I find it hard to believe that their isn't a comprehensive list of "user actions" by now.
I suppose that one would just visit the Microsoft page where the control was specified?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Events
« Reply #4 on: Nov 6th, 2015, 1:34pm » |
|
on Nov 6th, 2015, 10:35am, pnlawrence wrote:I suppose that one would just visit the Microsoft page where the control was specified? |
|
It's not likely to be very helpful. MSDN will list all the possible events that a control can generate, but it won't tell you which you get notified of in Liberty BASIC.
For example MSDN will tell you that a COMBOBOX can generate notifications when it gains or loses input focus, when the list drops down, when the selection is changed, when the contents of its edit box is modified etc. But the only one of those you get notified of in LB is the selection-changed event.
You should be able to find, in the LB Help docs, a description of what event(s) each control notifies you of. For example in the case of the COMBOBOX, under the description of eventHandler, it states "This is the branch label or subroutine where execution begins when the user selects an item from the combobox by clicking it".
But I've not seen them collated in one place.
Edit: As far as I know, this is the full list of events that can be generated by controls:
BMPBUTTON: When the button is clicked BUTTON: When the button is clicked. CHECKBOX: When the box is checked (sethandler) or unchecked (resethandler). COMBOBOX: When the selection changes. LISTBOX: When the control is double-clicked (or, if a SINGLECLICKSELECT command has been issued, when the selection changes). RADIOBUTTON: When the selected button changes (sethandler); the resethandler event occurs rarely and should usually be ignored.
There's an undocumented feature of LB whereby you can enable both single- and double-click events from a listbox. I do not support that in LBB, although I could.
Richard.
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: Events
« Reply #5 on: Nov 6th, 2015, 2:28pm » |
|
Geez, and here I was thinking of the enormous task in front of me and it all boils down to 6 events. I was incorrect in assuming the LB docs just couldn't be correct!
Quote:BMPBUTTON: When the button is clicked BUTTON: When the button is clicked. CHECKBOX: When the box is checked (sethandler) or unchecked (resethandler). COMBOBOX: When the selection changes. LISTBOX: When the control is double-clicked (or, if a SINGLECLICKSELECT command has been issued, when the selection changes). RADIOBUTTON: When the selected button changes (sethandler); the resethandler event occurs rarely and should usually be ignored. |
|
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
Re: Events
« Reply #6 on: Nov 7th, 2015, 12:27am » |
|
"There's an undocumented feature of LB whereby you can enable both single- and double-click events from a listbox. I do not support that in LBB, although I could."
I have a program that DOES use both single and double click events because I need to do two different things, and I didn't want to use a menu with only two choices. I hope you will support this feature in the future.
By happenstance, in that same program I get an error on this statement (which works in LB) Code:
today = val(date$("days"))
I had to use these two lines, instead
Code:
today$ = date$("days")
today = val(today$)
r.m.
|
|
Logged
|
|
|
|
joker
Global Moderator
member is offline
Gender:
Posts: 157
|
|
Re: Events
« Reply #7 on: Nov 7th, 2015, 01:29am » |
|
Alincon, you should have started another thread, because your problem with the date will get lost if someone searches.
Anything we can do to keep Richard engaged in updating LBB is a good thing!
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Events
« Reply #8 on: Nov 7th, 2015, 09:50am » |
|
on Nov 7th, 2015, 12:27am, Alincon wrote:By happenstance, in that same program I get an error on this statement (which works in LB). |
|
It only works in LB because of a bug. The docs clearly state that the function date$("days") returns a numeric value, not a string:
"print date$("days") ' 36127 returns number - days since Jan 1, 1901".
So of course if you do val(date$("days")) it is a Type Mismatch - the VAL() function expects a string parameter, not a numeric parameter.
The correct code (which will work in JB, LB 4.04, LB 4.5.0 and LBB) is:
Code: I won't be changing LBB to emulate the bug; the fault is in your program.
Richard.
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
Re: Events
« Reply #9 on: Nov 8th, 2015, 9:53pm » |
|
I agree that my code was wrong, your is right, and I should have known better.
Just one more question: why do you let both of these work?
Code:
today = date$("days")
today$ = date$("days")
r.m.
|
|
Logged
|
|
|
|
|