I'm trying to make Button change Label. When I run project and press button it does nothing.
Here is code for the button:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Label1->Text = "Hello" + Edit1->Text + " !";
}
Here is my View:
Related
My application is using two forms. When I click a panel in main form, the Form2 should showing up. There're a few pixels distance between the Main Form and Form2.
Now what I need is when I move the Main Form to anywhere, then Form2 moves where ever Main Form goes. I mean I need Form2 to be lock on Main Form.
Have the MainForm override the virtual WndProc() method to reposition Form2 as needed relative to the MainForm's current position whenever a WM_WINDOWPOSCHANGING or WM_WINDOWPOSCHANGED message is received.
class TMainForm : public TForm
{
...
protected:
void __fastcall WndProc(TMessage &Message);
...
};
...
#include "Form2.h"
...
void __fastcall TMainForm::WndProc(TMessage &Message)
{
TForm::WndProc(Message);
switch (Message.Msg)
{
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
{
if ((Form2) && (Form2->Visible))
{
Form2->Left = ...; // such as this->Left
Form2->Top = ...; // such as this->Top + this->Height
}
break;
}
}
}
is there an option to remove the keyboard from screen on iOS ? I use Tabris (http://developer.eclipsesource.com/tabris/) and Java in this context.
My problem is that i use two textfields to enter a user/passwort combination. After I filled these textfields and press a button to continue the keyboard from iOS is always shown but I want that the keyboard no longer appears. Only after I click somewhere then the keyboard disappears.
On Tabris, you can "open" the keyboard programmatically by setting the Focus on a Control which uses the keyboard (like org.eclipse.swt.widgets.Text ).
To hide the keyboard, just set the Focus to a Control which does not require a keyboard, like the parent composite of your Textfield.
In your case I would add al line to the SelectionListener of your Button to set Focus on the Parent of your Textfields, then start the Login procedure.
Here is some code to play and understand the Focus mechanism:
public class FocusTest implements EntryPoint {
public int createUI() {
Display display = new Display();
Shell shell = new Shell(display, SWT.NO_TRIM);
shell.setMaximized(true);
GridLayoutFactory.fillDefaults().applyTo(shell);
createContent(shell);
shell.open();
//while (!shell.isDisposed()) {
// if (!display.readAndDispatch()) {
// display.sleep();
// }
//}
return 0;
}
private void createContent(final Composite parent) {
Button buttonSingleText = new Button(parent, SWT.PUSH);
buttonSingleText.setText("Focus on SingleText");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonSingleText);
Button buttonMultiText = new Button(parent, SWT.PUSH);
buttonMultiText.setText("Focus on MultiText");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonMultiText);
Button buttonNoFocus = new Button(parent, SWT.PUSH);
buttonNoFocus.setText("Loose Focus");
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(buttonNoFocus);
final Text singleText = new Text(parent, SWT.SINGLE);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(singleText);
final Text multiText = new Text(parent, SWT.MULTI);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(multiText);
buttonSingleText.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
singleText.setFocus();
}
});
buttonMultiText.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
multiText.setFocus();
}
});
buttonNoFocus.addSelectionListener(new SelectionAdapter() {
#Override
public void widgetSelected(SelectionEvent e) {
parent.setFocus();
}
});
}
}
Did you set UITextField delegate and add the following method there?
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
I have one ImageButton in my android app, and I'd like the app to change the image while the button is pressed, and when the user release the button it returns to the default image.
P.S. I'm using mono for android and I have to do this programatically, I can't use the XML tag unfortunatelly.
You can hook into the views's Touch event to do that:
var button = FindViewById<ImageButton>(Resource.Id.MyImageButton);
button.Touch += (object sender, View.TouchEventArgs e) => {
if (e.Event.Action == MotionEventActions.Down) {
button.SetImageResource(Resource.Drawable.Icon);
} else if (e.Event.Action == MotionEventActions.Up) {
button.SetImageResource(Android.Resource.Drawable.IcMenuGallery);
}
};
I have a problem that popup menu appear when I click a button field. I will solve it by using Buttonfield.consumeclick but it also appears on RichTextField focus. How can I solve this? I am overriding RichTextField method, and that is the reason the popup menu appears.
ButtonField c = new ButtonField("button", FIELD_LEFT | ButtonField.CONSUME_CLICK) {
protected boolean navigationClick(int status, int time) {
Status.show("Button has clicked");
// write your code.
return true;
}
}
I have requirement for having onscreen navigation buttons along with menu items on blackberry. I need to generate menu item commands as onscreen buttons. Is there a way to generate onscreen menu item buttons in Blackberry? i.e On each screen of my application the menu items should be populated as onscreen buttons both having same functionality?
Thank you
The easiest way to accomplish what you're trying to do is write one function then have both the button and the menu item use the same function.
For example:
function doSomething() {
// Your Code Here
}
// In the function building your screen
MenuItem somethingMi = new MenuItem() {
private MenuItem() { super("Do Something",100001, 5); }
public void run() { doSomething() };
}
Button somethingBtn = new ButtonField("Do Something");
somethingBtn.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context){
doSomething();
}
}
addMenuItem(somethingMI);
add(somethingBtn);