Showing message without any buttons in Windows Phone - windows-phone-7

I would like to create an info message box in Windows Phone.
It should look like a single text message, that's shown on screen for X seconds, and I doesn't have any confirmation buttons
as MessageBox.Show() does. It would be used to show user some messages about the app progress, like "file download started",
or "preferences saved".
I've tried to create something like that, using Popup element, but it seems a bit different of what I want to
make.
With the popup I can create something like that
canvas.MouseLeftButtonUp += new MouseButtonEventHandler(popupCloseEvent);
For example, which closes this popup when user taps it.
or something similar. (Maybe can implement a timer there to close it after a few secs)
Are there better ways to create such thing?

You could use the either the Message Dialog or Overlay controls in the Coding4Fun toolkit.
Found here: http://coding4fun.codeplex.com/
They are really simple and easy to use controls.

Try this
In Xaml:
<Popup Tap="Popup_Tap"></Popup>
In code behind:
private void Popup_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
(sender as Popup).IsOpen = false;
}
I hope it helps.

Related

UI Button - activate buttons with keyboard input

this is probably dead easy but I can't find a solution. I made a dialogue system and have a UI-button to click when the player should display a sentence next.
The issue is that the button is only triggered onMouseclick and I would like to change the input button to Enter. Would anyone know how to go about this?
If you need to determine if the button is selected first or not, I suggest you take a look at this page: https://docs.unity3d.com/ScriptReference/UI.Selectable.IsHighlighted.html
If you don't want pressing the button to have any functionality, you just wouldn't link it to any functions.
Working code might look something like this:
public class selectableExample : Selectable{
BaseEventData _event;
void Update()
{
if (IsHighlighted(_event) == true)
{
if (Input.GetKeyDown("enter")){
print("replace me with working function"); // whatever you want to have happen on button press
}
}
}
}
You simply attach this to your button and it should respond the same as being pressed. To be honest, it hardly seems like you actually need a button at all for this though, you'd probably be fine with just a label telling the player to press "Enter" and then simply checking for that input.
You can use the Event Trigger component to use one of the many event types. Select Submit (this is set to enter and return in the input settings at edit>project settings>input by default).
Don't set anything in the OnClick event.
The only thing needed now is to actively highlight the button from somewhere with ReferenceToButton.Select().

wxWidgets event focus textcontrol

I have another wxWidgets question regarding events and focus.
I have already looked at the tutorials and this old question here but I am still running into problems C++ Event (Focus) Handling
Basically I have a dialog with two wxTextCtrl elements and a Button.
What I would like to achieve is, that when I click on button it needs to tell me which of the two elements previously had the focus.
In the constructor of my Dialog I created all the elements and then connected them to the eventhandler like this: Ttop->Connect(TOP,wxEVT_KILL_FOCUS,(wxObjectEventFunction)&UI_ADDENTRY::hasfocus);
Tbottom->Connect(BOTTOM,wxEVT_KILL_FOCUS,(wxObjectEventFunction)&UI_ADDENTRY::hasfocus);
then there is the eventhandler that safes the id into focus
void UI_ADDENTRY::hasfocus(wxFocusEvent& event){
focus= event.GetId();
event.Skip();}
however when i try to access focus in the Button function it always tells me: 0 instead of TOP or BOTTOM / the ids that I gave the textcontrols
void UI_ADDENTRY::OnRecord(wxCommandEvent &event){
wxString tmp;
tmp << this->focus;
wxMessageBox(tmp);}
What am I doing wrong? is there another way of finding out which of the two textbox has been in focus last?
Thank you
The most fool proof way is to catch EVT_SET_FOCUS in your text controls and remember the last one that received it. This is not more difficult than what you are doing but should work without problems.
FWIW EVT_KILL_FOCUS can't, unfortunately, be consistently implemented on all platforms, in particular GTK+ doesn't give any information about the window focus is being lost to.
In think u mean event.GetWindow().GetId(). Though I'm not sure how ur casting from int to string.

Hide touch keyboard

Is it possible to not show system keyboard, when you tap textbox? Ive created custom keyboard and can work with textblock only, because of this i cant delete just parts of sentence.
If you set IsReadOnly to true then the user can still select the text in a TextBox to copy paste and the OS doesn't show the software input keyboard when selected. You can still alter the contents of the TextBox through code though. Eg;
<TextBox x:Name="ExampleTextBox"
IsReadOnly="True"
Text="Initial Content"
GotFocus="ExampleTextBox_GotFocus"
/>
And in your code behind;
private void ExampleTextBox_GotFocus(object sender, System.Windows.RoutedEventArgs e) {
ExampleTextBox.Text += " ... focused!";
}
Would prevent the user from entering text via the software keyboard but will append "... focused" everytime they give focus to the TextBox. Contrived example, but you get the idea.
The only other thing I'd suggest is to re-style the TextBox. By default when IsReadOnly is set the TextBox will provide visual cues that it can't be modified by the user. Which isn't the case here.
if the user touches the keyboard, the keyboard will get focus.
the only option you as a developer have is to catch it and call this.focus moving focus away from textbox.
This will however mean that there will be a flicker where default keyboard pops up and is hidden.
I know this because i have a keyboard app. There is no other way.

Create a windows panel that is invisible that still accepts click message

I'm using c++/cli with visual studio 2010 express edition.
What I want to do is create a panel that is invisible but that still accepts/receives the click and double click messages and possibly other mouse input. If I set the controls visibility to FALSE then this seems to disable any mouse input.
I have tried getting the paint message and doing nothing (as was suggested by other sources) to try and make the panel simply not draw but not be invisible however the panel still seems to be drawing.
What should I be doing in the paint message to tell windows that I have draw the panel?
My panel drawing function is:
private: System::Void panel1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
}
If there are any other suggestions about how I could achieve this then that would be helpful.
In the end I scrapped this idea all together, the problem was to get a way of getting the mouse input from a window that had been "parentented" by a NativeWindow class. This meant that the window I was expecting to receive messages (the child window) was not receiving the messages.
In order to get the messages you need to override the event handler in your parent NativeWindow class. Here you can handle the event This is where I got the solution:
http://msdn.microsoft.com/en-us/library/system.windows.forms.nativewindow.createhandle.aspx

ImageMap behavior for tiles

Is it possible to determine the area on which a user clicked on a tile? Just like an image map in HTML. I would like to specify two buttons at an image tile and carry out different actions for each of them.
No. It is not possible to do this.
With respect of lauching your app, the tile works just like a shortcut on your PC desktop.
If you really need the behaviour you describe you'll have to create 2 applications - 1 for each launch action.
You can use something like this for every UI element.
private void ListBox_MouseEnter(object sender, MouseEventArgs e)
{
string pos= e.GetPosition(CanvasForLoop).X.ToString();
}

Resources