New topic: Controlling window resizing
<http://forums.realsoftware.com/viewtopic.php?t=47498> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message eduo Post subject: Controlling window resizingPosted: Thu Apr 04, 2013 2:51 am Joined: Sun Jun 24, 2007 12:24 pm Posts: 429 Location: Madrid Hi. tl;dr: I need a way to have a 500px vertical window to jump from 500px to 800px when resized vertically and viceversa, 500px is the minimum height of the window in "collapsed" mode and 800px is the minimum height in "expanded" mode. l;r: I've tried searching this around but "control" as a verb is impossible to search in a forum about RealStudio, as all hits end up being about controls themselves I'm wondering (and I assume it's possibly very simple) how to control how a user resizes a window. At the moment the window in question can only be resized vertically (easy by setting minimum and maximum widths) but vertically, I need to control how the user resizes it so it can only be done in "steps". You've probably seen a similar behaviour in palettes, where you can extend vertically but the palette will extend in fixed amounts, only allowing full sections to be added. In my case it's something similar. A drawer-like section of the window is usually collapsed, and currently can be expanded by double-clicking, but I want it to be expandable by dragging, which means I need that vertical resizes are ignored until they've reached a minimum Y length, and then snap-resize to that minimum size and from then on allow free extension. Similarly, if the window is reduced vertically it would stop the resizing when reaching this minimum height for the drawer and then snap it shut if you went past a threshold. I've tried catching the mousedown, mouseup and mousemove events, but something always makes it trip (switching apps or windows mid-resize, resizing too quickly). There isn't an event for "Presizing" where I can catch the resize event before it's effected until the vertical threshold is reached. The idea is to add visual feedback to this, once in place. But I'll tackle that when I get the resizing working. Thanks for suggestions. _________________ ---- http://eduo.info/ http://gallery.eduo.info/ http://twitter.com/eduo/ Top doofus Post subject: Re: Controlling window resizingPosted: Thu Apr 04, 2013 3:45 am Joined: Thu Sep 10, 2009 2:50 am Posts: 387 Location: Santa Cruz, CA, USA eduo wrote:I've tried catching the mousedown, mouseup and mousemove events, but something always makes it trip (switching apps or windows mid-resize, resizing too quickly). There isn't an event for "Presizing" where I can catch the resize event before it's effected until the vertical threshold is reached. The Resizing event seems to fire before the actual size change, so it's "Presizing", giving you a chance to change it. This works on a mac, maybe other OSes handle it differently. Sub Resizing() dim relativeY As integer = System.MouseY - self.Top if relativeY < 450 then self.Height = 300 else self.Height = 600 end End Sub Edit: This only works for Cocoa. Carbon doesn't restrict the size, Carbon+Composite does restrict but has weird graphical scrolling. If this doesn't work for you then I think you'll have to turn Resizable off and handle the resize entirely yourself. Which means drawing the resize widget, changing the cursor, capturing mousedown... Edit 2: OK, it'll work by also setting the Min and Max Height, so the height is locked in until you change it Sub Resizing() dim relativeY As integer = System.MouseY - self.Top if relativeY < 450 then self.Height = 300 else self.Height = 600 end self.MinHeight = self.Height self.MaxHeight = self.Height End Sub Top eduo Post subject: Re: Controlling window resizingPosted: Thu Apr 04, 2013 7:53 am Joined: Sun Jun 24, 2007 12:24 pm Posts: 429 Location: Madrid doofus wrote:eduo wrote:I've tried catching the mousedown, mouseup and mousemove events, but something always makes it trip (switching apps or windows mid-resize, resizing too quickly). There isn't an event for "Presizing" where I can catch the resize event before it's effected until the vertical threshold is reached. Edit 2: OK, it'll work by also setting the Min and Max Height, so the height is locked in until you change it Sub Resizing() dim relativeY As integer = System.MouseY - self.Top if relativeY < 450 then self.Height = 300 else self.Height = 600 end self.MinHeight = self.Height self.MaxHeight = self.Height End Sub Great catch, thanks. In my tests I couldn't stop the resizing from resizing but it was because of this. Thank you so much for the time figuring it out. _________________ ---- http://eduo.info/ http://gallery.eduo.info/ http://twitter.com/eduo/ Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
