(J2ME polish) Click gesture for touchscreen support - java-me

im trying to follow this, but got no luck. I'm using treeItem or Choicegroup and it can be selected but can't be clicked, like when clicked, it will go to the next page.
I don't wanna use X and Y coz my Item is dynamic which it was generated through XML. therefore, the item location will be changed. I want a touch pointer for a specific item like the choice group that Im using.
http://www.enough.de/products/j2me-polish/documentation/lush-ui/touch-support.html#gesture-click

You have Choicegroup and you want that on click of item it should go to next page then:
you can use :
choicegroupname.addCommand(command of Command.OK type, say commandOpen);
then,you can set setItemCommandListener to commandOpen and in commandAction you can traverse choicegroup so that you can get focused index and you do your code there,then break.Hope this helps.
you can do this like:
commandOpen.setItemCommandListener(new ItemCommandListener() {
public void commandAction(Command cmd, Item arg1) {
//size will be count of items
for(int i=0 ; i < size ; i++){
if(choicegroupname.focusedIndex== i){
//Do your code
return;
}
}
}
});

Related

Dialog RunBase custom lookup: Alt + Down key combination doesn't work

MS Dynamics AX 4.0
I have a class with a dialog that extends RunBase, a dialogField of Range type and a custom lookup for it. It works as planned but one thing upsets me.
Normal lookup opens on Alt + Down key combination, but it doesn't work in my dialog. I assume this is because "Range" EDT is not related to any TableField.
But I have my own lookup, can I force it somehow to drop down on Alt + Down?
Here is my dialog method:
protected Object dialog(DialogRunBase dialog, boolean forceOnClient)
{
Object ret;
;
ret = super(dialog, forceOnClient);
dialogFld = new DialogField(ret, typeid(Range), 100);
dialogFld.init(ret);
dialogFld.lookupButton(FormLookupButton::Always);
dialogFld.fieldControl().replaceOnLookup(false);
return ret;
}
Here is my lookup, as you can see, it's based on ItemId EDT:
protected void Fld100_1_Lookup()
{
TableLookup_RU sysTableLookup = new TableLookup_RU();
Query query = new Query();
FormRun lookupForm;
QueryBuildDataSource qbds = query.addDataSource(tablenum(InventTable));
;
sysTableLookup.parmTableId(tablenum(InventTable));
sysTableLookup.parmCallingControl(dialogFld.fieldControl());
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));
findOrCreateRange_W(qbds, fieldnum(InventTable, ItemType), SysQuery::valueNot(ItemType::Service));
sysTableLookup.parmQuery(query);
lookupForm = sysTableLookup.formRun();
dialogFld.fieldControl().performFormLookup(lookupForm);
}
And dialogPostRun:
public void dialogPostRun(DialogRunbase dialog)
{
;
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);
super(dialog);
}
This problem is not that critical, but it bothers me. If someone could help, I'd be really grateful.
P.S.: I could use ItemId typeId, but I need to append many items, and ItemId is only 20 chars long..
I've discovered that I don't have to use Range typeid for the dialogField. dialogField.limitText(int) works just fine, it overrides the length of EDT. So I changed dialog method like this:
protected Object dialog(DialogRunBase dialog, boolean forceOnClient)
{
Object ret;
;
ret = super(dialog, forceOnClient);
dialogFld = new DialogField(ret, typeid(ItemId), 100); //if typeId doesn't have relations Alt + Down doesn't work
dialogFld.init(ret);
dialogFld.label("#SYS72708");
dialogFld.lookupButton(FormLookupButton::Always);
dialogFld.limitText(200);
dialogFld.fieldControl().replaceOnLookup(false);
return ret;
}
Create a new extended data type ItemIdRange, extend from Range.
Be sure to set the relation on the new type to relate to InventTable.ItemId to get automatic lookup.
Also the form control must have property ReplaceOnLookup set to no, to allow the user to add more criteria. For a DialogRunbase field this may be done this way:
FormStringControl fsc = dialogField.control();
fsc.replaceOnLookup(false);
The code posted in the question is then not needed.

Unity Vuforia Google VR - Can't make onPointerEnter to GameObject change material for itself

I have two 3d buttons in my scene and when I gaze into any of the buttons it will invoke OnPointerEnter callback and saving the object the pointer gazed to.
Upon pressing Fire1 on the Gamepad I apply materials taken from Resources folder.
My problem started when I gazed into the second button, and pressing Fire1 button will awkwardly changed both buttons at the same time.
This is the script I attached to both of the buttons
using UnityEngine;
using UnityEngine.EventSystems;
using Vuforia;
using System.Collections;
public class TriggerMethods : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
Material _mat;
GameObject targetObject;
Renderer rend;
int i = 0;
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1"))
TukarMat();
}
public void OnPointerEnter(PointerEventData eventData)
{
targetObject = ExecuteEvents.GetEventHandler<IPointerEnterHandler>(eventData.pointerEnter);
}
public void OnPointerExit(PointerEventData eventData)
{
targetObject = null;
}
public void TukarMat()
{
Debug.Log("Value i = " + i);
if (i == 0)
{
ApplyTexture(i);
i++;
}
else if (i == 1)
{
ApplyTexture(i);
i++;
}
else if (i == 2)
{
ApplyTexture(i);
i = 0;
}
}
void ApplyTexture(int i)
{
rend = targetObject.GetComponent<Renderer>();
rend.enabled = true;
switch (i)
{
case 0:
_mat = Resources.Load("Balut", typeof(Material)) as Material;
rend.sharedMaterial = _mat;
break;
case 1:
_mat = Resources.Load("Khasiat", typeof(Material)) as Material;
rend.sharedMaterial = _mat;
break;
case 2:
_mat = Resources.Load("Alma", typeof(Material)) as Material;
rend.sharedMaterial = _mat;
break;
default:
break;
}
}
I sensed some logic error and tried making another class to only manage object the pointer gazed to but I was getting more confused.
Hope getting some helps
Thank you
TukarMat() is beeing called on both buttons when you press Fire1. If targetObject is really becoming null this should give an error on first button since it's trying to get component from a null object. Else, it'll change both as you said. Make sure OnPointerExit is beeing called.
Also, it seems you are changing the shared material.
The documentation suggests:
Modifying sharedMaterial will change the appearance of all objects using this material, and change material settings that are stored in the project too.
It is not recommended to modify materials returned by sharedMaterial. If you want to modify the material of a renderer use material instead.
So, try changing the material property instead of sharedMaterial since it'll change the material for that object only.

Error while editing grid view record

I got following error while i am clicked edit button on grid view for 2 page
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
can you please specify what should i have to do to remove this error
following is the code for edit command, It works well when i am on first page but gives erro if i goes to another any page in grid view
protected void GVviewReminder_RowCommand(object sender, GridViewCommandEventArgs e)
{
lblError.Text = "";
if (e.CommandName == "Edit")
{
GridViewRow selectedRow = GVviewReminder.Rows[Convert.ToInt32(e.CommandArgument)];
string ID = selectedRow.Cells[1].Text;
Response.Redirect("edit_health_reminder.aspx?HealthReminderIsOpen=true&id=" + ID);
}
}
The error log says index out of range so look at collections.
GVviewReminder.Rows[Convert.ToInt32(e.CommandArgument)]
selectedRow.Cells[1].Text

How to get the tab ID from url in DotNetNuke

I have an url (e.g. http://localhost/Aanbod/Pagina.aspx) and I want to know the tab id, so I can make a friendly url with query (e.g. http://localhost/Aanbod/Pagina/QueryKey/QueryValue/).
Anyone has an idea?
Edit:
I'm not on the page itself. Want to know it from any page possible.
The url does not contain the tab id itself, so it can't be extracted.
if Pagina.aspx is a page in dotnet nuke like Home or Getting Started then you can find the tab id by
DotNetNuke.Entities.Tabs.TabController objTab = new DotNetNuke.Entities.Tabs.TabController();
DotNetNuke.Entities.Tabs.TabInfo objTabinfo = objTab.GetTabByName("Pagina", this.PortalId);
int Tabid = objTabinfo.TabID;
Well, this post is a little bit old, and I don't know if someone still looks for a solution. I had this problem recently and here is the pieces of code I wrote to solve it:
public int GetTabIDFromUrl(string url, int portalID)
{
int getTabIDFromUrl = 0;
// Try the "old" way with the TabID query string
if (url.ToLower().IndexOf("tabid") > 0)
{
Int32.TryParse(Regex.Match(url, "tabid[=/](\\d+)", RegexOptions.IgnoreCase).Groups[1].Value, out getTabIDFromUrl);
}
// When there is no result (because of advanced or human friendly or whatever Url provider)
if (getTabIDFromUrl == 0)
{
TabCollection tabs = TabController.Instance.GetTabsByPortal(portalID);
foreach (KeyValuePair<int, TabInfo> k in tabs)
{
TabInfo tab = k.Value;
if (tab.FullUrl.StartsWith(url))
{
getTabIDFromUrl = tab.TabID;
break;
}
}
}
return getTabIDFromUrl;
}
This could be a pain with sites that have a lot of pages, therefore it could be useful if you have some additional information to shrink the list that you have to loop through - e.g. a ModuleId of a module that is placed on this tab:
public int GetTabIDFromUrl(string url, int moduleID, int portalID)
{
int getTabIDFromUrl = 0;
// Try the "old" way with the TabID query string
if (url.ToLower().IndexOf("tabid") > 0)
{
Int32.TryParse(Regex.Match(url, "tabid[=/](\\d+)", RegexOptions.IgnoreCase).Groups[1].Value, out getTabIDFromUrl);
}
// When there is no result (because of advanced or human friendly or whatever Url provider)
if (getTabIDFromUrl == 0)
{
IList<ModuleInfo> modules = ModuleController.Instance.GetTabModulesByModule(moduleID);
foreach (ModuleInfo module in modules)
{
TabInfo tab = TabController.Instance.GetTab(module.TabID, portalID);
if (tab.FullUrl.StartsWith(url))
{
getTabIDFromUrl = tab.TabID;
break;
}
}
}
return getTabIDFromUrl;
}
Hope that helps someone...
Happy DNNing!
Michael
I hope this will solve your issue
http://www.willstrohl.com/Blog/EntryId/66/HOW-TO-Get-DNN-TabInfo-page-object-from-TabId
Sorry, my bad!!
Here is your answer
http://www.dotnetnuke.com/Resources/Forums/forumid/118/threadid/89605/scope/posts.aspx :)

Highlight the selected cell in a DataGridView?

In my code below, I'm showing a context menu when the user right-clicks on a cell in my DataGridView. I'd also like the cell that the user right-clicks on to change background color so that they can see the cell they've "right-click selected". Is there a way to add something to my code below so that this occurs?
private void dataGridView2_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
MenuItem mnuCopy = new MenuItem("Copy");
mnuCopy.Click += new EventHandler(mnuCopy_Click);
m.MenuItems.Add(mnuCopy);
int currentMouseOverRow = dataGridView2.HitTest(e.X, e.Y).RowIndex;
m.Show(dataGridView2, new Point(e.X, e.Y));
}
}
So obviously you've hacked into my workstation and have seen some of the stuff I've worked on recently. I exaggerate a bit because I didn't do exactly what you're trying to do but with a little bit of tweaking I was able to.
I would modify your MouseClick event to get the DGV's CurrentCell. Once you have it, set the CurrentCell's Style property with the SelectionBackColor you want. Something like this:
// ...
DataGridView.HitTestInfo hti = dataGridView2.HitTest(e.X, e.Y);
if (hti.Type == DataGridViewHitTestType.Cell) {
dataGridView2.CurrentCell = dataGridView2.Rows[hti.RowIndex].Cells[hti.ColumnIndex];
dataGridView2.CurrentCell.Style = new DataGridViewCellStyle { SelectionBackColor = System.Drawing.Color.Yellow};
}
//...
The above is a bit 'air code-y' (in other words I haven't attempted to merge it with your code and run it) but I hope you get the idea. Notice that I check through the hit test that a cell was clicked; if you don't do this and the user does not click a cell you might have some problems.
Now there's the problem that this code will change the SelectionBackColor for the all the cells you right click. That's easy to restore this property in the DGV's CellLeave event:
private void dgvBatches_CellLeave(object sender, DataGridViewCellEventArgs e) {
dataGridView2.CurrentCell.Style = new DataGridViewCellStyle { SelectionBackColor = System.Drawing.SystemColors.Highlight };
}
I'll have to remember this visual affect; thanks for asking the question.

Resources