More

FlexViewer 2.1 - Add scroll for widgetgroup

FlexViewer 2.1 - Add scroll for widgetgroup


I have a site that is using the ArcGIS Viewer for Flex version 2.1. In the header I have a widget group that contains 25 items. The list is so long that it goes beyond the bottom of the browser window and I can't see the last 5-6 items. Is it possible to add scroll capability to the widgetgroup so I can scroll through the items?

Thanks, Tim


Robert Scheitlin provided an answer over on the ArcGIS Viewer for Flex forum. Link:

http://forums.arcgis.com/threads/36322-FlexViewer-2.1-Add-scroll-for-widgetgroup

His answer:

"Sure just find this block of code and make the changes indicated in red in the HeaderControllerWidget.mxml:"

    

Since the red doesn't appear here, I needed to add theparts, and modify the widgetList properties towidth="{widgetListDG.width + 29}" height="300".


XNA GUI: Creating a 'scroll pane' widget

I'm trying to create a simple GUI system and am currently stuck on how to implement a textarea with a scrollbar. In other words, the text is too large to fit into the view area. I want to learn how to do this, so I'd rather not use an already rolled API.

I believe this could be done if the text were part of a texture, but if the game had a lot of unique dialog, this seems expensive.

I researched creating a texture on the fly and writing to it, but came up with nothing.

Any suggested strategies would be appreciated. I believe it boils down to: text in a texture and how? Or something I have not thought of.


3 Answers 3

I finally managed to figure it out, after hours of coding around (I'm new to Magento 2)

All you need to do is a dependency injection on

Create a helper with the _prepareForm method, which we want to rewrite:

where we set $config['add_widgets'] and (if you also want to) $config['add_variables'] to true. Adjust the return statement and your done with your helper.

Create/Edit your di.xml and define a preference:

I don't know if this ist the best and proper way to do it, but it actually works on CE 2.0.4.

And don't forget to add filter methods to your frontend output.

In case anyone is wondering how to do this in Magento 2.1.x (and probably 2.2+ as well). Here's how:

Create your own custom module and add view/adminhtml/ui_component/category_form.xml with (at least) the following code in it:

This will add the variable and widget buttons to the description-field when you're editing a category. But the widgets/variables need to be rendered as well on the frontend, otherwise you would just see the widget tags appear as text on the frontend (this was the question asked by anujeet).


add_filter() and add_action() are available before any plugin is loaded. So you can use both in the first line of your plugin or theme.

For readability I recommend to group action and filter registrations at the very top of your main file:

There are exceptions for that rule:

    . In this example I register an action for shutdown only when the first filter for wp_nav_menu_objects has been called. So the second callback cannot be registered at the same time as the first one.

OOP style. Sometimes you have to set up class members before you can register the callbacks. Using a very similar example …

… we see the instantiation of the class can be stopped by another plugin, and a child class could register more or different filters and actions.

In addition to grouping you can go a step further and offer a custom action to make customizations for other developers easier.
Here is an example from a theme I am working on:

The last line is important: A child theme or a plugin can hook into the action t5_theme_hooks_registered now and unregister any previous hook. That will save struggling with priorities, and I am free to change my callback priorities any time.

But do not rely on source code order alone. Document the hooks you are using in your doc block. I am using a custom tag wp-hook for that. Here is an example with chained hooks from the same theme:

You don’t have to scroll up to see where these functions are called, one look at the doc block is enough. This requires some efforts, because you have to keep both in sync, the registration and the comment, but in the long run it saves valuable time.


A demo widget

To illustrate the inner workings better I have written a very simple demo widget:

Note the constructor: 't5_demo_widget' is the $id_base , the identifier for this widget. As you can see in the screen shot its arguments are stored in the option widget_t5_demo_widget . All your custom widgets will be treated like this. You don't have to guess the name. And since you have written your widgets (probably) you know all the arguments from your class' $instance parameters.


The first design is the worst in terms of usability because the icon is ambiguous, and there's a real possibility that the user won't even see it. The user is going to be focused on (ie, reading) the dropdown menu and s/he can't process the icon at the same time it's physically impossible. You're counting on the user to either find the icon by chance or by an educated guess.

The second design is a bit more usable because the Add option is more prominent though it still has the same limitations. It depends on how wide the dropdown is and how prominent the Add option is.

The third design is probably the safest of the three because it guarantees that the user will at least scan the existing list. It's not the prettiest, but it's the most intuitive.

A fourth option would be to put the a text link underneath the dropdown menu, where the user has a very high chance of seeing both. You could disable the text link and then enable it once the user has activated the dropdown menu.

Based on the answer from @tim-huynh and the smart comment from @monkeyzeus, here's my two cents.

  1. Design 1 is ambiguous: user can think the icon means "add this group to something" before triggering the tooltip.
  2. Design 2 is better but still, I agree that a non-educated user won't be able to guess that the "new group" option will be to the right-behind her locus of attention, as @tim-huynh states.
  3. Design 3 is a nice start:
    1. the "new group" option is near the user's locus of attention,
    2. it is always good to provide the user an overview of the existing groups/tags/options before enabling her to create a new one,
    3. still, this design fails at long lists, because the "New Group" button will be placed far down the list (which can exceed the screen height in some cases).

    The solution I suggest is to implement an advanced select widget, like the smart guys at Gmail did for thei tag button below (sorry for the italian terms. "Etichetta" means "Tag")

    • the tag-list is scrollable and has a fixed height, which enables the "New tag" ("Crea nuova" in the image, a "+" icon would have been nice here) button to be always visible,
    • if the list is too long, the user has a searchbar to quickly find what she looks for (my girlfriend has, like, 70+ tags and doesn't even consider scrolling).

    I think the first and third options are both possibilities, depending on how it will be used.

    If the user will need to add items quite frequently, the + button is definitely preferable out of those two, because it will be annoying to go through the list every time to get to "add new". If it might be a very long list of items, this will also increase the annoyance of getting to the "add new" option.

    I would recommend going with the first option as it a clear visual indicator that users can add a new item to the list if not found. Here is an example of how you might do it

    The challenge with the third option is that you are expecting the user to scroll to the bottom of the list before he finds the option to add a new item. If the items in your list are organized alphabetically and the user is scanning alphabetically, after the particular alphabet is over the user might scan any further

    The second option can also work but the concept of a link is a not a strong call to action might be overlooked in reference to the dropdown.

    I would go with the 2nd option because it clearly states the action and there is little or no ambiguity. Either you select one of existing groups from the dropdown or create your own. User experience cannot get simpler than that!

    1st option could also work, but requires some action on users behalf. I assume the tooltip is shown only with a mouse hover and, thus, doesn't trump 2nd option in its simplicity.

    However, this approach might be neater out of design and aesthetics perspective. A small simple (+) button looks better than a text link (and in the case of app internationalization you never know how long your UI text strings are going to be and where it might break a line and create a mess).

    So to make it work, you could show the tooltip in the beginning, but hide it permanently when user has created a new group once or twice, and, thus, knows what this button does.

    Needless to say, it would require some user preference/data storage functionality (maybe localStorage which is accessable in all modern browsers http://caniuse.com/#feat=namevalue-storage, or if more users are expected using your app from a single device/pc then store it in the backend. )

    3rd option is clearly worst of them all. User has to needlessly discover a crucial part of functionality, which could be very hard if the list of groups is large and requires scrolling.

    I would like to add that The third option will depend on the size of the list. If the dropdown is very long, you might want to consider a predictive search, and then use that term to "Add New Group" if it's not found.

    If this is a high volume page it's worth investigating with analytic tools to find out for sure.

    Ideally you could investigate your users using web analytics to determine the best answer for your user base expectations. clicky.com, for example, allows you to time each duration between the click on the form element above the item group and the form element after the item group field. Then you look at the analytic timing diagram and do a histogram of the duration users spend on the "item group" field.

    You don't necessarily need to do this timing analysis with an A/B setup if you want you can just pick one, build, and check for severity of design flaws later. later, you look at the histogram of just people who choose the "add new category" option and check for out of sequence use (they didn't see it at first and had to go back up to that form element later). If you have a large enough sample size you should see distinct peeks in the timing histogram with each peak representing a different user models time to recognize the functionality. As a fun exercise, you can profile the distinct groups of your users base by looking at the peaks in the timing histogram and assigning each peak to a different user mental model without the need for a survey or other annoying feedback mechanism normally used for segmenting an audience.