MGWT ScrollPanel Snaping - mgwt

I am using the scrollpanel in mgwt to display images and i want it that when the user scrolls the closest image snaps to the top. i see there are two methods of the scrollpanel for snapping
void setSnap(boolean snap)
void setSnapSelector(String selector)
I can't find any documentation on setSnapSelector. Can anyone tell me what this method does? And what it is supposed to be passed?

If you want to see an example of the snap selector in action take a look at the HeaderList widget: http://code.google.com/p/mgwt/source/browse/src/main/java/com/googlecode/mgwt/ui/client/widget/HeaderList.java
If you enable snap and set a selector the scrollPanel will snap to a position after any touch. So if you have several images you want to pass img as a selector.

Related

Properly aligning a ListView in react-native

I have a screen in my react-native app where I am showing details of a record. It's a pretty simple screen where on the left column, I have a label describing the item and on the right, I have the value of the item. For one of the values, I have to render a ListView and I am not able to properly align it. Below is the sample app on rnplay with the symptoms:
Sample app on rnplay
Please run on iOS. Here ComponentListView is a reusable component that I am using to render ListView and it takes a component and data as it props and render each entry in the data using the passed in component. Here the list is BackupList and the component to render in each row is BackupSummary. If you run the app, you will observe that the backups are not aligned properly. I ran it in the Inspector on the simulator and looks like the ListView starts from where Varun Accepted is seen. I am not sure why. Right now there is just one item in the this.props.backupContacts but there could be more. I have tried many different flexbox properties such as alignItems, justifyContent, alignSelf in order to get it to work with no success.
Please let me know if you know how to fix it.
Put your ListView inside a View and apply css on View, something like this
<View style={{display:'flex', flexDirection:'row', justifyContent:'center'}}>
<ListView/>
</View>

How to create an mgwt widget which extends from FlexPanel and TouchWidget

I have several escenarios where some mgwt widgets which do not extend TouchWidget need to be "touchable", for instance ScrollPanel or FlexPanel.
One scenario is a full screen widget wich reacts when user touches it and shows a popup.
Java do not let extending two classes, so I want to reuse code from both the widget and the TouchWidget (which has a final static TouchWidgetImpl in it)
Thanks
You don't need to make a FlexPanel into a TouchWidget. You can add a TouchWidget to a FlexPanel, and let it occupy the entire screen.

how to set lwuit textarea scrolling false

I want to add large string content to a container dynamically.
There are 60 different contents(strings) to be displayed in this container.
To add the string to container, I am adding a TextArea(empty border with 100% transparency).
The problem is that TextArea offers scroll and I do not want it to scroll. Instead I want to grow(increase height) according to content. I am unable to achieve this.
Can you help me out with this?
Or can I use any other component for the purpose?
I am using LWUIT with J2ME.
You can derive text area and return false for isScrollableY() although it should generally work seamlessly even if you don't do that (since your parent layout is scrollable). Is it possible you changed the text area and don't revalidate the parent form on the EDT?
There are problems with text area layout when it is modified by a separate thread (race condition with the layout code).
First put the TextArea.setSingleLineTextArea(false) , and grow by content true.

OrchardCMS - Can't find correct alternative to render widget

I'm trying to add a image carousel to my CMS site and in the process learn about Alternatives.
I've go the following content types
BannerImage (TextField and a MediaPicker field)
ImageGallery (Container)
I've created a bunch of images, added them as 'Containables' to a new ImageGallery and
I then create a widget, put it in BeforeContent and it renders as an ugly list (default rendering)
I have been able to customize the images by using the alternative Content-BannerImage.Summary.cshtml, sweet.. so far so good.
BUT I'm not able to customize the rendering of the ImageGallery at all. The alternative
Content-ImageGallery.Summary.cshtml or .Detail or even Widget-Container.cshtml do not work at all.
The alternative that IS being used is Widget.Wrapper.cshtml which came with the theme I'm using. I'm not able to find the correct alternative so I can prevent the ImageGallery from rendering it's name/title (which it does by default from the Widget.Wrapper.cshtml alternative.
Any help is greatly appreciated and before it's mentioned... I've read http://docs.orchardproject.net/Documentation/Accessing-and-rendering-shapes which is a great doco, but I'm too dumb to figure it out :)
Ta
To create an alternate (not alternative) for a widget, you first have to activate the Widget Alternates module.
Once you have done so, create your widget, and activate the Shape Tracing module. Go to the page where the widget appears, click on the shape tracing button on the bottom right corner to show the shape tracing and select your widget.
You should now see a list of possible alternates for your widget. Select one and click the link to create it. Now you just have to edit it to your taste.
Depending on how the image gallery module you're using is working, the shape that you need to override to render the list of images. It is probably the List shape that you need to change. This article should give you a good starting point: http://weblogs.asp.net/bleroy/archive/2011/03/27/taking-over-list-rendering-in-orchard.aspx

LWUIT, How to create a custom label for form title

I want to know how to create a label that contains two icons, one on each side and set it as the title bar for the form element (LWUIT widgets).
Form has a function to get a titleArea then you can put some components what you want.
Form f = new Form();
Container c = f.getTitleArea();
Label iconLabel1 = new Label("leftIcon");//using Image
Label iconLabel2 = new Label("rightIcon");//using Image
c.addComponent(BorderLayout.WEST, iconLabel1);
c.addComponent(BorderLayout.EAST, iconLabel2);
You can just add a component to the north portion of the screen which is the recommended way that will work properly and won't break for newer versions of LWUIT/Codename One.
When you don't set a title it will just work and you can give it the Title UIID. LWUIT 1.5 and newer have a TitleArea container but I suggest you stay away from it since CodenameOne customizes it quite allot for iOS/Android 4.x etc.
Use the setTitleComponent(Label title) method.
EDIT :
Derive the Label class and implement the paint method where you can use the Graphics method to draw Images and texts. Also set the label's text position to Label.CENTER .

Resources