I have a login page in my app which uses UITextField element. I want to hide the keyboard when I click away from that TextField.
I tried using this code that I saw on a website in my ViewDidLoad function but it didn't work.
EntryTextField.ShouldReturn = (textField) =>
{
textField.ResignFirstResponder();
return true;
};
I solved the problem by adding these lines to ViewDidLoad():
View.UserInteractionEnabled = true;
UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(HideKyb);
tapGesture.NumberOfTapsRequired = 1;
View.AddGestureRecognizer(tapGesture);
and I added this line into the HideKyb function:
View.EndEditing(true);
Related
I am creating an addon and for that i have successfully connected di and ui api. i am creating everything (forms, buttons, textbox etc ) manually by code to learn as this is my first one. when i debug i can see my form with all the fields i created. here is the code for form creation.
SAPbouiCOM.FormCreationParams oCreationParams = null;
oCreationParams = ((SAPbouiCOM.FormCreationParams(SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)));
oCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed;
oCreationParams.UniqueID = "Form2";
oForm = SBO_Application.Forms.AddEx(oCreationParams);
oForm.Title = "Simple Form";
oForm.Left = 417;
oForm.Top = 520;
oForm.ClientHeight = 610;
oForm.ClientWidth = 770;
here is how i create my button
SAPbouiCOM.Button oButton = null;
oItem = oForm.Items.Add("Button1", SAPbouiCOM.BoFormItemTypes.it_BUTTON);
oItem.Left = 6;
oItem.Width = 65;
oItem.Top = 51;
oItem.Height = 19;
oItem.Enabled = true;
oButton = ((SAPbouiCOM.Button)(oItem.Specific));
oButton.Caption = "Add";
the problem is when i try to add the values of textbox in database on button click event, i am not able to generate a button click event.
from my knowledge when we create a button from toolbox and uses system form, it automatically initializes the button ON InitializeComponent() function and also creates a delegates pointing to button click event.
May i know how to achieve all these through code.
i tried to initialize button through my manual code and also created delegates pointing to a button click function but i was unable to achieve my result.
Try adding a method that captures SAP B1 item events like this:
public void HandleItemEvent(ref SAPbouiCOM.ItemEvent pVal)
{
if (pVal.BeforeAction == false && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "Button1")
{
// You code here
}
}
I have a layout that I want to show as a popup window (used as a custom options menu) while in a fragment of a viewpager. Therefore, when the "Options" button is clicked, I do the following:
public void onOptionsButtonClicked(int buttonHeight)
{
LayoutInflater optionsLayoutInflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
int popupWidth = ViewGroup.LayoutParams.MatchParent;
int popupHeight = ViewGroup.LayoutParams.WrapContent;
View layout = optionsLayoutInflater.Inflate(Resource.Layout.TrackOptions, null);
int popupYOffset = (85 + buttonHeight) * -1;
var popup = new PopupWindow(context);
popup.Focusable = true;
popup.Width = popupWidth;
popup.Height = popupHeight;
popup.ContentView = layout;
popup.SetBackgroundDrawable(new BitmapDrawable());
popup.OutsideTouchable = true;
popup.ShowAsDropDown(view, 0, popupYOffset);
}
And this works as I want, visually that is. Meaning, I click the button and I do see the layout popup as a popup window with all of my options. HOWEVER, none of the buttons work. I put a breakpoint in the class that should be associated the the layout and noticed that onCreateView never gets called, therefore, none of the buttons and associated click event handlers are ever wired up. So, I know why it is not working. However, I don't know how to fix it. I think it is because, while I inflate the view, I am never actually creating the fragment. I have done fragementmanager transactions to replace a fragment in other parts of my project and I know that would probably do it, however, this is a different case as I am trying to do a popup window.
Thanks!
Mike
Fragment is attach in activity so you can try it in onActivityCreated(Bundle) method
This is the code I have for the button. I want the configbutton to display a pop up window when clicked on. I have looked up and tried a lot of different codes but none of them work. I feel like I am missing a key component but I am not sure what that is. Appreciate the help!
tr = new TableRow();
// Create the cell
tc = new TableCell();
tc.Width = Unit.Point(300);
tc.BorderWidth = 0;
tc.BorderStyle = BorderStyle.None;
Button ConfigButton = new Button();
ConfigButton.Text = "Configuration";
ConfigButton.Visible = true;
tc.Controls.Add(ConfigButton);
tr.Cells.Add(tc);
tbl.Controls.Add(tr);
Using JavaScript Along with ASP.NET you will do the following:
// when you create the button, you can add attributes
Button ConfigButton = new Button();
// this example will display alert dialog box
ConfigButton.Attributes.Add("onclick", "javascript:alert('ALERT ALERT!!!')");
// to get you popup windows
// you would use window.open with the BLANK target
ConfigButton.Text = "Configuration";
ConfigButton.Visible = true;
I recommend looking into using the AJAX Control Toolkit ModalPopupExtender. This is what I use for my pop ups in ASP.NET.
Here is a link to he AJAX Control Toolkit samples website showing how this control works:
http://www.ajaxcontroltoolkit.com/ModalPopup/ModalPopup.aspx
I'm using Visual Studio 2013 and LightSwitch. I figured out how to create a delete record button and it works great. The only problem I have is on my main page where all records are shown.
When the page loads, The View & Edit buttons only appear once I select a record. the Add and Delete are visible all the time. The problem is, while the delete function works, it only works when a record is selected. So, if the page loads and you click delete it errors out. I would like to hide the delete button until a record is clicked on. By default the Edit and View buttons that Lightswitch creates do this, however since you have to write your own Delete function I have not figured out how to do this.
Here is an example of the C# i'm working with which works fine provided a record is selected..
myapp.BrowseGiftRegistries.DeleteRegistry_execute = function (screen) {
screen.GiftRegistries.deleteSelected();
return myapp.commitChanges().then(null, function fail(e) {
myapp.cancelChanges();
throw e;
});
};
In the delete button's _canExecute() method just put the following code:
myapp.MyScreen.DeleteButton_canExecute = function (screen) {
return screen.GiftRegistries.selectedItem != null;
};
You can also control whether the button is visible when disabled by checking or unchecking the "Hidden if disabled" checkbox in the properties for the selected button.
You should do it on client side using javascript(it seems that you have provided javascript code).
For example, if you have delete button named 'DeleteRegistry':
Add code below to your BrowseGiftRegistries.lsml.js
myapp.BrowseGiftRegistries.created = function (screen) {
screen.findContentItem('DeleteRegistry').isEnabled = false;
//screen.findContentItem('DeleteRegistry').isVisible = false;
};
// Function created by clicking List( Gift Registries)->properties window->
// ->Actions->Item tap->None->edit execute code
myapp.BrowseGiftRegistries.GiftRegistry_ItemTap_execute = function (screen) {
screen.findContentItem('DeleteRegistry').isEnabled = true;
//screen.findContentItem('DeleteRegistry').isVisible = true;
};
// Modification of your function
myapp.BrowseGiftRegistries.DeleteRegistry_execute = function (screen) {
screen.GiftRegistries.deleteSelected();
screen.findContentItem('DeleteRegistry').isEnabled = false;
//screen.findContentItem('DeleteRegistry').isVisible = false;
return myapp.commitChanges().then(null, function fail(e) {
myapp.cancelChanges();
throw e;
});
};
You can replace line containing isEnabled field with commented line containing isVisible field to reach result you need.
I try to create a UIBarButtonItem with a custom view for a Toolbar. The view itself is displayed well, but when i click the BarButton, no action occurs. It looks like the touch event is not forwarded from the view to the UIBarButtonItem instance. I have checked the responder chain and i think it looks good. I have also searched the internet and checked the Apple documentation, but can't find any hint for my problem.
Here is my code:
g__objWeatherButton = new UIBarButtonItem[1];
UIView l__objCustomView = g__objWeatherDisplay.InfoBarButton; // Returns a reference to my custom view
UIBarButtonItem l__objButton = new UIBarButtonItem(l__objCustomView);
l__objButton.Clicked += delegate {this.WeatherButtonEvent();}; // my action handler
l__objButton.Width = 200;
l__objButton.Enabled = true;
g__objWeatherButton[0] = l__objButton;
this.Items = g__objWeatherButton; // "this" is my UIToolbar object
Can someone give me a hint where the problem is? Or a working code sample (in c# please - have found some examples in Objective-C, but apparently overlooked the crucial trick ;-)
No special trick. When you want to add a custom view to a toolbar or navigation bar, you should subscribe (and respond) to that view's events. So instead of using a UIView to hold your image, create a UIButton with UIButtonType.Custom and subscribe to that button's TouchUpInside event.
You then initialize it like you do with the UIView:
UIButton l__objCustomUIButton = UIButton.FromType(UIButtonType.Custom);
//l__objCustomUIButton.SetImage(UIImage.FromFile("your button image"), UIControlState.Normal);
l__objCustomUIButton.TouchUpInside += delegate { this.WeatherButtonEvent(); };
UIBarButtonItem l__objButton = new UIBarButtonItem(l__objCustomUIButton);
Just make sure you declare the button in the class scope.
Although the answer put me in the right direction I still had trouble displaying the button. Only after I added the following the was button display with image.
l__objCustomUIButton.Frame = new System.Drawing.RectangleF(0, 0, 40, 40);
Regards
Paul
There is an easier way and the custom button will now react like a regular toolbar button.
this.SetToolbarItems( new UIBarButtonItem[] {
new UIBarButtonItem(UIBarButtonSystemItem.Refresh, (s,e) => {
Console.WriteLine("Refresh clicked");
})
, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) { Width = 50 }
, new UIBarButtonItem(UIImage.FromBundle
("wrench_support_white.png"), UIBarButtonItemStyle.Plain, (sender,args) => {
Console.WriteLine("Support clicked");
})
}, false);