Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg104679] Re: [mg104671] How to make floating control elements?
  • From: István Zachar <replicatorzed at gmail.com>
  • Date: Sat, 7 Nov 2009 06:44:07 -0500 (EST)
  • References: <200911673522.697620@jfultz2winlap>
  • Reply-to: zac at freemail.hu

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án 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: Mathematica skill level snippet(s)
  • Next by Date: Re: Passing function arguments as lists of replacement rules
  • Previous by thread: Re: How to make floating control elements?
  • Next by thread: Re: How to make floating control elements?