How to set a clear button in textfield for android in titanium? - titanium

I am trying to set a clear button in text field using clearbuttonmode where it is working fine with Ios Platform and is not showing up in android.

Since clearButtonMode (check your spelling) is only available for iOS as you can see in the documentation I would go the multiplatform way and create a own button and add it next to the TextField. The buttons just sets the TextField value to "" to clear the field. You could even put everything inside a <View> with a white background and a border so it will look like the clear Button is inside the TextField
pseudo code:
<View height="Ti.UI.SIZE" width="300">
<TextField left="0" right="40"/>
<Button width="40" right="0"/>
</View>

Related

Material UI button label colour won't change after changing disabled state

After changing programmatically the "disabled" parameter of Material UI button the labels' color won't change on Safari. (It works for Chrome).
CodeSandbox link:
https://codesandbox.io/embed/material-demo-forked-8ly0d
According to this issue https://github.com/mui-org/material-ui/issues/26251
you need to add a prop key to your <Button> component to force it to re-render:
<Button key={`${disabled}`} disabled={disabled} />

Calculating a popover position from a button click, instead of an SVG inside the button

I have been struggling for the past few hours to get a button click to work. The button contains text and an SVG, when clicking on it it opens a popover component.
The popover calculates its position on the element that was clicked upon. This works when clicking on the button itself, but when clicking on the SVG inside of the button, the dimensions/offsets from the SVG are used to calculate popover position instead.
What am I looking for: a way to bubble the click on the SVG to the button, then using the event object from the button click to calculate the popover position.
How my button with events looks like right now:
<button type="button"
#click="popButtonClicked">
Go do magical stuff
<svg path="" />
</button>
I have tried playing with #click.modifiers on both the button and SVG, but to no avail.. Hope someone has the answer for me! :)
You can get the button's reference by passing the $event as a parameter to your function, and then accessing the .currentTarget of that reference:
<button type="button"
#click="popButtonClicked($event)">
Go do magical stuff
<svg path="" />
</button>
And then in your function:
popButtonClicked (event) {
console.log(event.currentTarget)
}
Working codepen: https://codepen.io/anon/pen/gdBBdz

Problems using a composite view in Titanium Alloy

I am trying to implement a simple app in Alloy that has a very basic structure but I cannot get it to layout reliably. I am trying to bottom align a group of navigation buttons with a working area above them which in the following example would be a TableView.
<Alloy>
<Collection src="book">
<Window height="100%" id="main" title="My Library {opts.username}" exitOnClose="true" onOpen="loadExtras">
<TableView id="content" dataCollection="book" top="10px" bottom="100px" onDragEnd="refreshTable">
<TableViewRow title="{title}" color="black" onClick="showBook"/>
</TableView>
<View bottom="0px" height="72px" layout="horizontal" id="actionPanel">
<Button class="footerBtn" onClick="refreshTable">View</Button>
<Button class="footerBtn" onClick="refreshTable">Help</Button>
<Button class="footerBtn" onClick="refreshTable">List</Button>
<Button class="footerBtn add" onClick="addBook"></Button>
</View>
</Window>
The only way I can get this to work is to specify a height for the TableView such as height="80%" and then play with this value until things layout as I would prefer but I do not want to do as I need this to work independently of the devices physical screen size.
How can I implement this kind of layout in Alloy to get a view to pin to the bottom of the screen with a variable working area above it - or, do I have to assume a standard height and work relative to that?
Try pinning the table to the bottom of the parent view and then setting the height to be 80% of the parent view height. Also, use dp values to be screen independent.
<TableView id="content" height="80%" bottom="100dp"
onDragEnd="refreshTable"
dataCollection="book">

How to make button invisible but it's content should be visible in xaml

Below is code for my button, so what properties should I add to make button invisible but content must be visible.
<Button x:Name="PART_PreviousButton"
DockPanel.Dock="Left"
Content="<"
Focusable="False"
Opacity="0" />
You need to edit the button Template to have this kind of result.
This link explains it pretty well, the easiest way is to do it with blend: http://msdn.microsoft.com/en-us/library/bb613598.aspx

How to make a button event in pure xaml

I have this code
<Image Name="LightOn_BMP" Source="Res/LightOn.bmp" Canvas.Left="150" Canvas.Top="10" />
<Image Name="LightOff_BMP" Source="Res/LightOFF.bmp" Canvas.Left="150" Canvas.Top="10" />
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOn">
<Image Name="SwitchDown_BMP" Source="Res/SwitchDown.bmp" />
</Button>
<Button Canvas.Left="215" Canvas.Top="150" Click="PowerOff">
<Image Name="SwtichUp_BMP" Source="Res/SwitchUp.bmp" />
</Button>
And I want in pure XAML to make the PowerOn event to change so that LightOn.bmp is visible and LightOff.bmp is hidden and hide the Switchdown.bmp picture/button
Then I should be able to figure out how to make the event for the PowerOff
Simply put, you can't. The whole idea behind WPF is that you should separate behavior from display. So, at least without making some crazy black magic, you won't be able to change the state of the Image object (visible to false).