LB Booster
Programming >> BASIC code examples >> Split pane demo
http://lbb.conforums.com/index.cgi?board=code&action=display&num=1480434730

Split pane demo
Post by Richard Russell on Nov 29th, 2016, 2:52pm

One of the features of LBB is that the WHEN mouse events work in a window of type WINDOW as well as a window of type GRAPHICS. This allows you to do some things that would not be as straightforward in LB 4.5.

Here's a very simple demo of a window which is split into two texteditor controls (they could just as well be any other kind of control). You can move the split point by dragging it horizontally with the mouse. It uses an embedded BBC BASIC statement to switch the cursor to a double-pointed-arrow, something which isn't so easy in LB (would anybody like me to add some more cursor types to LBB?).

Code:
    WindowWidth = 600
    texteditor #w.te1, 0, 0, 290, 300
    texteditor #w.te2, 294, 0, 290, 300
    open "Pane test" for window as #w
    #w "when leftButtonMove resize"
    !MOUSE ON 132
    wait
    
sub resize h$, x, y
    #w.te1 "!locate 0 0 ";x-2;" 300"
    #w.te2 "!locate ";x+2;" 0 ";WindowWidth-x-18;" 300"
    #w "refresh"
end sub 

Richard.
Re: Split pane demo
Post by RNBW on Nov 29th, 2016, 4:35pm

Richard

Nice bit of useful code!

You can still move the seperator without !MOUSE ON 132, but it's much more like you normally get with Windows with the double headed arrow hovering above the seperator.

It could be useful to know more !MOUSE cursor types.
Re: Split pane demo
Post by Richard Russell on Nov 29th, 2016, 4:44pm

on Nov 29th, 2016, 4:35pm, RNBW wrote:
It could be useful to know more !MOUSE cursor types.

If you use !MOUSE ON you can of course look up the choices in the BBC BASIC documentation. What I was suggesting is that I could extend the native LBB CURSOR statement to support a wider range of pointer types.

I'm thinking that the simplest option would be to use exactly the same approach as LB adopts with the RULE command: i.e. allowing you to use either preset names or Windows constants. This would allow you to do:

Code:
    CURSOR _IDC_SIZEWE 

Richard.

Re: Split pane demo
Post by RNBW on Nov 29th, 2016, 6:47pm

Richard

Thank you, I've looked up in the BBC documentation and the MOUSE types and number references are all clearly identified (as expected).

I very rarely use LB these days. I only use it if there is a need to check out something in LB. I more often than not use LBB. The reason being that it does things properly rather than some of the weird ways of LB. So, I think I'll just stick to the !MOUSE format.

I recently converted a program I had written in QB64 into LB/LBB. I was surprised how easy it was. All I had to change was Labels (label: to [label]) and Using (using "##.##"; var to using ("##.##",var).

I know the program was simple, but the effort was worth it. I didn't get LB to write console programs, but it does show how the MainWin can be used for other purposes than debugging.