Using MonoDroid, how can I open a dialog when an EditText field gains focus? - dialog

I made the EditText clickable but you have to "double-click" to bring the dialog box up, which isn't really desired behaviour. How can I bring the dialog box up when the EditText is clicked / gains focus?
Bonus points for including a way to stop the keyboard popping up :)
_createProfileDobEdtTxt.Clickable = true;
_createProfileDobEdtTxt.Click += (sender, e) =>
{
ShowDialog(DATE_OF_BIRTH_DIALOG);
};

I found it - use the .Touch event handler:
_createProfileDobEdtTxt.Touch += (sender, e) =>
{
ShowDialog(DATE_OF_BIRTH_DIALOG);
};

Related

Disable Dialog closing after ENTER button pressed in ControlsFX

I have extended org.controlsfx.dialog.Dialog and added some TextField to it, which is supposed to act when ENTER button is pressed (if TextField has focus). However when I press ENTER, my dialog takes over of steering, and act like on OK button was pressed.
Is there any method which I can override in order to change this behavior (to intercept Enter action)?
Thanks in advance
I have received some workaround to this problem at ControlsFX mailing list which is good for me. To disable Dialog closing after Enter button is pressed in TextField we must consume event in EventHandler attached to this TextField
textField.addEventFilter(new EventHandler() {
public void handle(KeyEvent evt) {
.......
evt.consume();
}
});
For me works this:
dialog.getDialogPane().addEventHandler(KeyEvent.KEY_PRESSED, event -> {
if (event.getCode() == KeyCode.ENTER) {
event.consume();
}
});

Displaying a subview on button click

I am developing an ios app in xamarin .How to display a subview(i have used xcode IB for creating a subview) when a button is clicked.Then when i click the same button, again subview must be displayed.If button is pressed 3 times, 3 subviews must be displayed.
In a very common way it will be something like that:
yourButton.TouchUpInside += (object sender, EventArgs e) => {
var newView = new UIView();
// do some stuff with your view here
this.Add (newView);
};

How can identify Mouse Click event in PreTranslateMessage?

I want identify all mouse click event in PreTranslateMessage, but when I use WM_LBUTTONDOWN than WM_LBUTTONDBLCLK portion never called. Please tell me how can I identify all events separately.
This code will get the mouse click events in PreTranslateMessage
BOOL CSampleDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_LBUTTONDOWN)
{
//add ur customized code here...
return false;
}
return CDHtmlDialog::preTranslateMessage(pMsg);
}

Fire parent click event when child is clicked in windows form user control

I have a user control
public partial class ButtonControl : UserControl
which has two controls of label and picturebox
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.text = new System.Windows.Forms.Label();
I have used this control in a windows form
this.appointmentButton = new DentalSoft.UI.Controls.ButtonControl();
created an event
this.appointmentButton.Click += new System.EventHandler(this.appointmentButton_Click);
but the problem is, if i click on the image or the label inside of the control, the click event doesn't fire.
I want to fire this click event no matter where the user clicks inside of the control. Is it possible?
Yes it is a simple matter. When you click on the child controls they receive the click event and the user control does not. So you can subscribe to the child control click events and when they occur simply raise the usercontrol click event and it will appear to click no matter where the mouse is positioned.
Just double click on the picturebox and the label to create the click event handlers then add a line of code to call the parent usercontrol OnClick method.
private void text_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.OnClick(new EventArgs());
}
I solved this problem the following way. I wanted to changes the background images of the parent PictureBox when the child Label was clicked. I played around some and found I could call the event handler in the following way.
private void Label_Click(object sender, EventArgs e)
{
Label label = (Label)sender;
Box_Click(label.Parent, e);
}
private void Box_Click(object sender, EventArgs e)
{
//
PictureBox box = sender as PictureBox;
//
if (isMine[int.Parse(box.Name)])
{
box.Image = Image.FromFile(#"..\..\images\BoxRedX.jpg");
MessageBox.Show("Game Over");
}
else
{
box.Image = Image.FromFile(#"..\..\images\BoxGray.jpg");
}
}
As you can see I grab the Child and using it to reference its parent and send it to the parents click event. This is the code I used to work in my project. The important method is the first on listed. The second is there for clarity to see how it passed and worked.

Blocking action of CDialog's maximize/minimize button

I am using mfc CDialog. I need to show the close and minimize/maximize button, but they should not close or maximize the dialog. I have overriden OnClose method and kept the dialog open even if close button is clicked. But I am unable to block maximize and minimize of the dialog as there doesn't seem to be a OnMaximize method. Is there an alternative way?
You need to handle the WM_SYSCOMMAND message, watching for wParam == SC_MAXIMIZE.
If you catch the SC_MINIMIZE, you can do what you want and not pass it on to Windows.
msdn
Found this snippet here.
const int WM_SYSCOMMAND= 0x0112;
const int SC_MAXIMIZE= 0xF030;
protected override void WndProc(ref Message m)
{
if(m.Msg==WM_SYSCOMMAND)
{
if((int)m.WParam==SC_MAXIMIZE)
{
MessageBox.Show("Maximized!!");
return; // swallow the message
}
}
base.WndProc (ref m);
}
You can not show at all the minimise/maximise icons i your dialog. You can do that by going to Dialog properties (right vlick on your Dialog Contorol --> Properties), Select Styles pain and unselect 'Minimise Box', 'Maximise Box'.

Resources