how to position smartGWT dialog - smartgwt

I am trying for hours now to move my dialog in smartGWT, but with no luck.
This is my code:
Dialog dlg = new Dialog();
ListGridRecord[] h = scoringGrid.getRecords();
HLayout chart = new HLayout();
vlayout.addMember(chart);
dlg.addMember(highChart(h));
dlg.moveBy(500, 900);
dlg.setHeight("400px");
dlg.setWidth("700px");
dlg.show();
I also tried: setLeft, setTop, setRect, without any effect.
My dialog always displays at the same location.
Any ideas?

Dialog is a subClass of Window. So you can invoke the method setRect which is inherited.
From the Javadoc:
public void setRect(int left, int top, int width, int height)
// Set all four coordinates, relative to the enclosing context, at once.
If you don't see the change perhaps you would have to redraw in some cases I found it necessary.

I had the same issue. I finally tried calling moveTo() after show(), and it worked.
dlg.show();
dlg.moveTo(400, 500);
moveBy() works this way as well.
I'm not sure WHY this works--I'm guessing show() automatically centers the Dialog and overrides previous placement. However, I don't get the same behavior working with a Window, and I don't see anything in Dialog overriding the show() behavior. But, it worked for me....

Related

How do I control the auto-scroll of an iOS Xamarin editor when the soft keyboard appears?

I'm encountering some bizarre behaviour in a Xamarin Forms iOS Editor.
I have needed the editor to expand horizontally with the width of the text, rather than wrapping.
To achive this, I placed the Editor inside a ScrollView:
<local:ScrollViewEx x:Name="svContent" HorizontalScrollBarVisibility="Default" Orientation="Both"
BackgroundColor="Transparent">
<local:EditorEx x:Name="edContent"
VerticalOptions="Fill" HorizontalOptions="Fill"
WrapLongLines="False"
BackgroundColor="Transparent" />
</local:ScrollViewEx>
In the editor renderer, everytime the text changes, I resize the editor's height and width by getting new dimensions from the following method:
Size GetSizeThatFits()
{
CGSize newSize = Control.SizeThatFits(new CGSize(nfloat.MaxValue, nfloat.MaxValue));
return new Size(newSize.Width, newSize.Height);
}
This all works fine.
But when the editor takes focus and the soft keyboard appears, the system will always horizontally scroll to the maximum x value of the line where the cursor sits. This can cause the cursor to be moved offscreen, and will obviously create confusion for users.
I have tried to control the scrolling by holding the x value in place and only allowing an autoscroll of Y as follows:
private void Editor_Focused(object sender, FocusEventArgs e)
{
double x = sv.ScrollX;
Device.BeginInvokeOnMainThread(() =>
{
sv.ScrollToAsync(x, sv.ScrollY, false);
});
}
This succeeds in holding my x value in place, but now Y for some reason is being automatically set to zero, ignoring the value of sv.ScrollY.
Any ideas?
UPDATE 01
I've just tested the app on an iPhone12 device and the problem is even worse.
With every keystroke the scroll will jump to a different part of the screen.
Is there anyway to completely decouple the keyboard and my Editor/ScrollView scrolling? It would be easier for me to write my scrolling behaviour completely by myself than to keep fighting with the built in behaviour which is not making sense.
UPDATE 02
I may be getting a little closer to my goal.
By subclassing my UITextView and enclosing UIScrollView and overriding their scroll related methods I've manage to kill off most of their unpredictable scroll behaviour:
public override void ScrollRectToVisible(CGRect rect, bool animated)
{
//do nothing
}
public override void SetContentOffset(CGPoint contentOffset, bool animated)
{
//do nothing
}
However some remains. The following scenario is causing problems:
TextChanged event
Reconstruct a UIStringAttributes based on new text, and assign it to Control.AttributedText (Scroll has stayed stable up to this point)
Control.TextStorage.BeginEditing();
Control.AttributedText = astr;
Control.TextStorage.EndEditing();
The next click on the editor to trigger cursor position / SelectionChange however causes an editor scroll setting ScrollY, and sometimes ScrollX to zero.
Why????
Step 3 is hard for me to manage because SelectionChange occurs with both a click on the editor and the entry of text. It also occurs before a TextChange so is hard to predict the cause of SelectionChange.
In addition, even if I bypass Step 2 and don't manually reset my AttributedText, the jump at Step 3 still occurs.
Any ideas?

Simulate a click() programmatically on a Div

I'm trying to fire an event programmatically. My problem is that I have two SVG on two DIVs and I want to be able to change the border of the DIV I have clicked. To do that I thought to pass the DIV inside my classes and then trigger a click on it once I click on anything. (if there is a better way, please tell me)
I have the following code:
div = querySelector(divName);
svgElement = new svg.SvgSvgElement();
div.append(svgElement);
div.onClick.listen(_setBorders(1));
later I pass the svgElement to another class
ell.show(svgElement);
where show is
show(svg.SvgElement element) {
if (element.parent is DivElement){
_parentDiv= element.parent as DivElement;
element.children.add(_group);
}
}
_parentDiv is of course a DivElement, which I use for an internal onClick()
_onClick(MouseEvent e) {
window.console.info("onClick Ell");
_parentDiv.click();
}
I'm expecting to see the _setBorders(1); I defined with the main div, but it doesn't work. The weird thing is that when I check with the debugger set to the _parentDiv.click() I see that _parentDiv has the event correctly set.
I suppose click() doesn't work as I expected. Any Idea?
If you want that _setBorders(1) is called on click events you have to use :
div.onClick.listen((_) => _setBorders(1));

Blackberry jumpy scroll

I am having trouble with vertical scrolling on a blackberry app.
it works just fine on touch screens, but when scrolling using a track pad, it jumps from being at the top position to being at the bottom position.
Anyone had a similar problem? any idea what i could try?
Here is a snippet from my code. i have a static background image and the fields scroll on top of it:
vertical_main = new VerticalFieldManager(USE_ALL_WIDTH |NO_VERTICAL_SCROLL |USE_ALL_HEIGHT);
vertical_AllTags=new VerticalFieldManager(USE_ALL_WIDTH | VERTICAL_SCROLL);
// i then add all the fields to vertical_AllTags
vertical_main.add(vertical_AllTags);
vertical_main.invalidate();
add(vertical_main);
thanks in advance for your help
EDIT:
The suggestion of giving each field focus was correct. the only other part that needs to be done is when you override the onFocus method for a field, you need to call the super() function so that all the other normal parts of the onFocus method are still called:
protected void onFocus(int direction) {
text_select=true;
invalidate();
super.onFocus(direction);
}
protected void onUnfocus() {
text_select=false;
invalidate();
super.onUnfocus();
}
Thank you so much.
This is common issue in non touch devises for beginners.
if you want to scroll field by field there is two ways
1) you need to give the focus to all fields then it will come field by
field focus down
another way is means you dont need to focus on each and every field
2)just add the NullField after your every field and give focus to all
NullFields then your trackball will bring your screen field by field
This happends beacuse in TrackWheel Scrolling it scrolls up to the next Focused field. I think you are not give any focus between the vertical_AllTags.
You can solved this by using NullField() class. Like...
add(new NullField(Field.FOCUSABLE))
when you add add(new NullField(Field.FOCUSABLE)); you will get the null focus which is not know by you. And you can navigate all the fields like Touch Screen.
You can solve that issue by adding two vertical field manager.. take a look at the code in this post

Call QFileDialog when trying to edit cell in QTableView

Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate:
Won't have a native dialog.
I'll have to implement my own image preview,
For some reason I can't resize the window cause setGeometry doesn't work, etc etc.
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
In practice, everything that changes the geometry of your widget goes to updateEditorGeometry function. Override it to avoid trying the original one to put your dialog within the cell of the table.
OK so the editor->setGeometry method has to go in the overridden method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?

Blackberry Maps closing oddly. Not Google maps

I'm having some trouble finding documentation on CLOSING a blackberry map.
My map opens, albeit with some odd marker behavior, but when you close the map it displays a clear screen.
The invoke code is quite simple, as the map request calls a new controller and within the constructor is this:
String document = "<location-document>... etc";
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));
I tried to add a close line
public boolean onClose() {
UiApplication.getUiApplication().popScreen(this);
return true;
}
but this is not being applied to the map itself, but the page the map opened into. That's logical, I guess.
Maybe I'm going about this all wrong. I don't know of how to open a map another way, or if there is a way to have the close button close the map AND the containing screen.
Any help is appreciated.
I solved this with a simple one line function that fixed this problem.
public void onExposed()
{
UiApplication.getUiApplication().popScreen(this);
}
Adding that to the map controller closes the map application when the user clicks the back button. Simple as that.

Resources