An Assortment of Woopsi Changes

It’s been quiet around here lately. The weather has been gorgeous and I’ve been enjoying the first sunny week for 18 months. Knowing the English weather this is probably all the summer we’ll get. It’s already getting colder and I’m told it’ll be raining again by Friday.

Anyway, I’ve made a few fixes and changes that I haven’t got around to documenting yet. Most of the fixes are things that have been raised in the forum. Jeff pointed out an overflow problem with the slider grip calculations, which is now fixed. He also noted that the grip didn’t move as expected when the gutter or scrollbar buttons were clicked; that’s fixed too. The Gadget::addGadget() method will now apply the focus properly if a gadget is added that thinks it already has focus, and I’ve made a number of improvements to the focus system.

The way Woopsi handles clicked gadgets has also been improved. Rather than having a chain of clicked gadgets throughout the hierarchy, the Woopsi class now has a single pointer to the clicked gadget itself. Much tidier. Getting this working meant re-factoring some of the window and screen gadgets, which now rely more on straightforward event handling and have a lot less kludgy code.

Lastly, one for John - the MultiLineTextBox class will now handle single-line text properly. There were a number of problems with it. Firstly, the Text::wrap() function could get into a circumstance where it would read past the string terminator. Secondly, the Text::stripTopLines() function wasn’t recalculating the wrapping locations, which meant that it thought it had more lines than it actually did, and it didn’t know where those lines started or finished. Lastly, the MultiLineTextBox::setText() function wasn’t resizing its canvas properly. Along the way I fixed two of the vertical alignment options, top and centre, but the bottom alignment is still broken. There’s still a lot of potential improvements that could be made to this class.

There are a few new features. There’s a new “EVENT_RELEASE_OUTSIDE” event which gets fired when a gadget is released with the stylus outside the boundaries of the gadget. This is in addition to the usual “EVENT_RELEASE”, which gets fired when the stylus is within the gadget boundaries. Usually we’re only interested in the standard release event (for standard buttons), but there are situations where it is important to handle any release, such as releasing the window titlebar (in order to drop it to its new location).

Related to this, the EventArgs struct has two new properties - “eventVX” and “eventVY”, which are mainly used by the “drag” event to report how far the stylus was dragged.