private void RenderTableRows() { itsDataTableScrollViewPosition = KGFGUIUtility.BeginScrollView(itsDataTableScrollViewPosition, false, itsForceDisplayVerticalSlider, GUILayout.ExpandHeight(true)); { //Log List Heading RenderTableHeadings(); if (itsDataTable.Rows.Count > 0) { GUILayout.BeginVertical(); { Color aDefaultColor = GUI.color; for (int aRowIndex = (int)itsStartRow; aRowIndex < itsStartRow + itsDisplayRowCount && aRowIndex < itsDataTable.Rows.Count; aRowIndex++) { KGFDataRow aRow = itsDataTable.Rows[aRowIndex]; //Pre Row Hook if (PreRenderRow != null) { PreRenderRow(aRow, EventArgs.Empty); } if (aRow == itsCurrentSelected) { KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTopInteractive, GUILayout.ExpandWidth(true)); } else { KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVerticalInteractive, GUILayout.ExpandWidth(true)); } //Row { foreach (KGFDataColumn aColumn in itsDataTable.Columns) { //check if the column is visible if (itsColumnVisible[aColumn]) { //Pre Column Hook if (PreRenderColumn != null) { PreRenderColumn(aColumn, EventArgs.Empty); } bool aCustomDrawer = false; if (PreCellContentHandler != null) { aCustomDrawer = PreCellContentHandler(aRow, aColumn); } if (!aCustomDrawer) { // crate the string int itsStringMaxLenght = 85; string aString = aRow[aColumn].ToString().Substring(0, Math.Min(itsStringMaxLenght, aRow[aColumn].ToString().Length)); if (aString.Length == itsStringMaxLenght) { aString += "..."; } if (itsColumnWidth[aColumn] > 0) { KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.Width(itsColumnWidth[aColumn])); } else { KGFGUIUtility.Label(aString, KGFGUIUtility.eStyleLabel.eLabelFitIntoBox, GUILayout.ExpandWidth(true)); } } KGFGUIUtility.Separator(KGFGUIUtility.eStyleSeparator.eSeparatorVerticalFitInBox); //Post Column Hook if (PostRenderColumn != null) { PostRenderColumn(aColumn, EventArgs.Empty); } } } } KGFGUIUtility.EndHorizontalBox(); //check if the rect contains the mouse and the pressed mouse button is the left mouse button if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0) { itsClickedRow = aRow; } //only send this event on layouting if (OnClickRow != null && itsClickedRow != null && Event.current.type == EventType.Layout) { if (itsCurrentSelected != itsClickedRow) { itsCurrentSelected = itsClickedRow; //Debug.Log("itsCurrentSelected is set"); } else { itsCurrentSelected = null; } OnClickRow(itsClickedRow, EventArgs.Empty); itsClickedRow = null; //Debug.Log("itsClickedRow is set to null"); } //Post Row Hook if (PostRenderRow != null) { PostRenderRow(aRow, EventArgs.Empty); } } GUI.color = aDefaultColor; GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); } else { GUILayout.Label("no items found"); GUILayout.FlexibleSpace(); } } GUILayout.EndScrollView(); }