Window Splitters

Which version of Xojo are you using?

I was using the new if() statement which is not available in older versions of Xojo or RealStudio. This must have triggered that Syntax error. I replaced this code with a traditional style clause. A new commit is on github.

Sorry - I was away from my Mac.

I just re-downloaded it, and it now works.
I have noticed that the blue handle displays a different cursor than the black coloured handle - is that normal for a splitter?

There are OSX design guidelines which describe the cursors for splitters. At the moment I have just implemented the cursors for vertical movement (arrows pointing up and down) and the one for horizontal movement (arrows left and right)

There are still more cursors which one could implement, for docked splitters, with just one arrow pointing to the direction the splitter can undock. At the moment I have not implemented these cursors.

Cool -great work Oliver !

Oliver,
is there any way to prevent the splitter from resizing a control too small?

Example:
If I have a ListBox on the top half of my window, and a text area on the bottom half, (with the splitter in-between) - how can I prevent the user from moving the splitter up so that the top ListBox disappears?

Basically I need the top ListBox to always display at least 50 pixels, and also the bottom TextArea to also display at least 50 pixels.

Hope that made sense :slight_smile:

Thank you for the excellent control.

[quote=90482:@Richard Summers]Oliver,
is there any way to prevent the splitter from resizing a control too small?
….[/quote]
The first thing to do would be to set the properties MinBeforeArea or MinAfterArea to a value where you want the splitter to stop.

Another thing one can do is to write code in the SplitterMoved or MouseDrag event handlers, where one can calculate (and correct) the splitter position according to the actual requirements. One can also use the MoveSplitter method to programmatically move the splitter back to a calculated position.

See the readme which comes with the sample project.
https://github.com/oleman108/imSplitter

Oliver,
I have already tried changing the MinBeforeArea and the MinAfterArea to 200 - but it made no difference?

As a novice, I have no idea how to calculate and correct the splitter position :frowning:
Do you have any example code, which I could study and learn from?

The control is fantastic and I really want to use it, but am having serious trouble trying to set the minimum values :frowning:

Thank you.

If you study the included SplitterTest project then you can see a vertical splitter named imSplitter1.

imSplitter1.Left = 123
imSplitter1.MinBeforeArea = 20

And to its Left is Listbox1

Listbox1.Left = 20

Now in the IDE, select imSplitter1 and in the Position section of the Inspector, set MinBeforeAre to 100

imSplitter.MinBeforeArea = 100

Run and see where it stops, when you drag the splitter to the left.

But if you set the .MinBeforeArea to 200 then this is already beyond its starting .Left value (=123), so this does not really work.

This is the first thing you should set up correctly in your own project, and only then you should think about maybe adding a MouseDrag eventhandler and in there you write code:

Pseudo Code:

If x < 100 Then Me.MoveSplitter(100-x) End If

You could also evaluate against a calculation. For instance if you do not want the splitter to move over the right edge of a textarea1, then you write something like this:

Dim l As Integer = (textarea1.Left+textarea1.width) If x < l Then Me.MoveSplitter(l-x) End If

And in order to use x and y in the MouseDrag event in a meaningful way, you will have to save the initial x and y in the MouseDown event to some properties you will have to define yourself. Then you can calculate the difference and the final values to be sent to the MoveSplitter method.

Or here, some code i just was digging out from a real project. The splitter is set up to change width of some fields, here a combobox and a textfield. With this code I prevent the widths to go below a certain value:

[code] If coText.Width < 70 Then
Dim l As Integer = imSplitText.Left - 70 - imSplitText.Width - tfNo.Width - imSplitNo.Width
Dim diffX As Integer = l - Me.Left
Me.MoveSplitter(diffX)
End If

If tfDate.Width < 80 Then
Dim l As Integer = tfDate.Left + 80
Dim diffX As Integer = l - Me.Left
Me.MoveSplitter(diffX)
End If[/code]

Thanks Oliver, all is now working perfectly !

@Walter Ferlazzo : Did you find an answer yourself?