MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to make floating control elements?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104680] Re: [mg104671] How to make floating control elements?
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Sat, 7 Nov 2009 06:44:19 -0500 (EST)
  • Reply-to: jfultz at wolfram.com

If the control were allowed to grow when you clicked on it (as your current
prototype does), then I could imagine embedding the entire interface in a 
graphic, making the slider a Locator, and using ControlActive to control the
appearance when the control is in use.  This would allow for more accurate 
tracking then your prototype does now.  But you have specced the problem pretty 
tightly to require popup behavior, and I think only PopupWindow or a similar
style solution are general enough for what you want.

Another possibility would be to lay out all of the controls in a graphic. That 
would allow a control to grow and simply overlay neighboring controls.  But
layout out neighboring elements in a graphic without the benefit of things like 
Row, Column, and Grid is a pain in the butt.  The resulting solution might do 
exactly what you want, but it would be far from elegant.

Sincerely,
 
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.

..
On Fri, 06 Nov 2009 17:19:31 +0100, Istv=E1n Zachar wrote:
> Thanks for the fast reply, here are the details.
>
> What I want to construct is a simple control to increase/decrease a
> numerical variable,
> one that looks like the compact controls e.g. in Corel Photopaint. It's
> hard to describe,
> so here is the code I created so far (only the relevant core of my
> function):
>
> {x, d, pushed} = {1, 1, False};
>
> Deploy@Dynamic@Grid[{
> If[pushed, #, Take[#, 2]] &[
> {InputField[Dynamic@x, FieldSize -> {3, 1}],
> Column[{
> Button[
> Graphics[Polygon[{{1, 0}, {0, .6}, {-1, 0}}]], (x = x + d),
> ImageSize -> {17, 7}, Appearance -> "Palette"],
> EventHandler[
> Button[Graphics[Line[{{-50, 0}, {50, 0}}]], (False),
> ImageSize -> {17, 3},
> Appearance -> {"Palette", If[pushed, "Pressed", "Normal"]}],
> {"MouseDown" :> (on = True; diff = Last@MousePosition[];
> pushed = True; def = x),
> "MouseDragged" :> (x = def - (Last@MousePosition[] - diff)),
> "MouseUp" :> (on = False; pushed = False)}
> ],
> Button[
> Graphics[Polygon[{{1, 0}, {0, -.6}, {-1, 0}}]], (x = x - d),
> ImageSize -> {17, 7}, Appearance -> "Palette"]
> }, Spacings -> -.3],
> Panel[
> VerticalSlider[x, {Min[x, def - 100], Max[x, def + 100]},
> Appearance -> Tiny, ImageSize -> {10, 80}], FrameMargins -> 0]
> }]
> }, Alignment -> {Left, Top}, Spacings -> 0]
>
>
> Basically it has a step-down and a step-up button, and a button in
> between them, that acts like a slider to allow
> fast changes. Athough the visual feedback is only there (i.e. the real
> slider only appears) if the button is pushed
> and the mouse is dragged. Since I use this control a lot in a dense
> interface, it is not possible for the slider to appear
> after/below the control buttons, as it would shift every other control
> around, and also the mouse looses focus if the
> mid-button moves a bit, which messes up the release-event (just try to
> replace the last Alignment -> {Left, Top} with {Left, Center}).
>
> I've also tried to create a Tooltip window to appear immediately only if
> the mid-button is down, but the problem is that
> if I drag the mouse out of the control area (the whole
> InputField+ButtonBar set), the tooltip is gone.
> I don't really want to have an extra window, as you suggested it. It
> seems a bit unnecessary and perhaps would
> have side-effects according to Windows...
>
> Can it be solved elegantly, or I do have to rely on PopupWindow?
>
> Istvan
>
>
> John Fultz wrote:
>> You seem to be asking, what are the component parts of
>> PopupMenu/PopupView, and
>> how can you access the floating window component.  In Mathematica,
>> PopupMenu
>> (or, more technically, the PopupMenuBox, as PopupMenus are represented
>> in the
>> front end) is the most atomic part you can get to.  PopupView is a thin
>> layer
>> wrapping PopupMenu.
>>
>> You don't explain what you're trying to do, and it's difficult for me
>> to comment
>> on alternative methods that might be available to you.  I will say that
>> you
>> really can do quite a lot with PopupMenu and its close cousin,
>> ActionMenu.
>>
>> Alternatively, you could create a button which pops up a frameless
>> notebook
>> window.  This would be sort of an extended version of how PopupWindow is
>> implemented.  You'd probably find that you'll eventually run into some
>> limitation where you can't do exactly what you want to do, but maybe
>> not.
>>
>> Sincerely,
>>
>> John Fultz
>> jfultz at wolfram.com
>> User Interface Group
>> Wolfram Research, Inc.
>>
>>
>> On Fri, 6 Nov 2009 05:18:03 -0500 (EST), Istv=E1n wrote:
>>
>>> Dear Group,
>>>
>>> I would like to create a custom control, with a floating element, that
>>> appears if one of the buttons in the control is pushed. The floating
>>> box would be (technically) similar to the dropdown list of PopupView
>>> or PopupMenu, which appears without shifting things (e.g. other
>>> controls) below the popup control.
>>> I tried to figure out the low-level structure of the popup commands,
>>> but there's nothing in the doc.center about the floating component.
>>> I guess I can solve my problem just by using PopupView, but in this
>>> way I cannot fully customize the appearance and position of the
>>> dropdown box, and I still cannot create a standalone floating box (to
>>> link it to e.g. a custom graphics in EventHandler) as PopupView still
>>> has a button.
>>> Perhaps the option MenuAppearance is responsible for such things, but
>>> it is undocumented.
>>>
>>> Can anyone help on this?
>>>
>>> Istvan Zachar





  • Prev by Date: Re: Passing function arguments as lists of replacement rules
  • Next by Date: Re: Finding Clusters
  • Previous by thread: Re: How to make floating control elements?
  • Next by thread: Writing a graphic to a notebook, cont