标签: custom-component

Ref 不适用于 Vue3 中的自定义组件

我正在使用 Vue3 和组合 API。在表单组件中,我在每个字段(子组件)上放置了引用。

\n

由于某些原因,ref自定义组件的 与refQuasar 组件的 不同。

\n

当我console.log使用ref自定义组件时,我在 DevTools 中得到以下信息:

\n
Proxy\xc2\xa0{__v_skip: true}   \n
Run Code Online (Sandbox Code Playgroud)\n

(Target 中没有任何属性)

\n

而对 Quasar 组件的引用给出了:

\n
Proxy\xc2\xa0{\xe2\x80\xa6}  \n
Run Code Online (Sandbox Code Playgroud)\n

(包含 Target 中组件的所有属性)

\n

因此,我无法使用ref来访问这些子组件的属性或方法。

\n

我什至不知道是什么__v_skip意思。\n我的自定义组件是用 定义的script setup,这可能是一个原因吗?

\n

知道如何解决这个问题吗?

\n

更新\n如果我defineExpose在子组件中使用我想使用 a 从外部访问的属性和方法ref,它确实有效。但不太方便,因为这些组件有很多道具。

\n

ref custom-component vue.js quasar vuejs3

9
推荐指数
1
解决办法
8286
查看次数

Delphi编译器警告指向Delphi自己的单元

在Delphi 2007中,处理一个包含自定义组件的项目,当我进行完整构建时,我将这组警告作为消息中的前四个警告(但不是在我进行直接编译时):

[DCC Warning] Dialogs.pas(1426): W1002 Symbol 'TFileOpenDialog' is specific to a platform
[DCC Warning] Dialogs.pas(1446): W1002 Symbol 'TFileSaveDialog' is specific to a platform
[DCC Warning] ComCtrls.pas(6757): W1036 Variable 'Section' might not have been initialized
[DCC Warning] ComCtrls.pas(19268): W1023 Comparing signed and unsigned types - widened both operands
Run Code Online (Sandbox Code Playgroud)

我通常会尽力消除编译器警告,但这些都是"库存"德尔福单位.这些警告是否是我代码中某些内容的间接结果?如果是这样,我该如何找出/在哪里?如果没有,我该怎么办呢?

ide delphi compiler-construction custom-component

8
推荐指数
2
解决办法
2971
查看次数

更改所选JToggleButton的背景颜色

我试图以JToggleButton可靠,外观和感觉独立的方式改变它的颜色.

如果使用Metal L&F,那么使用UIManager是一种方法:

UIManager.put("ToggleButton.selected", Color.RED);
Run Code Online (Sandbox Code Playgroud)

注意:Iyy指出我上面的属性名称中有一个拼写错误,但我会将其留在上面,以便人们到达这里,但实际的属性名称应该是:

UIManager.put("ToggleButton.select", Color.RED);
Run Code Online (Sandbox Code Playgroud)

但是,这在我目前的外观(目前是Windows XP)中不起作用.经过一些进一步的分析,似乎Windows中的系统外观(仍然是XP)根本不使用任何Color基于UIManager属性的属性ToggleButton,或者它至少不提供它们本身(有一个在线快速查找的UIManager例子)来自的所有属性键,在示例中明确地明确限制Color属性).

我试过设置背景颜色:

Action action = new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) { /* stuff */ }
};
JToggleButton button = new JToggleButton(action);
// tried with and without opaque true
button.setOpaque(true);
button.setBackground(Color.RED);
Run Code Online (Sandbox Code Playgroud)

它不仅不会改变选定的状态,而且甚至不会影响未选择的状态.

我在尝试接收动作后尝试更改背景颜色:

@Override
public void actionPerformed(ActionEvent e)
{
    JToggleButton button = (JToggleButton)e.getSource();
    if (button.isSelected()) // alternatively, (Boolean)getValue(Action.SELECTED_KEY)
    {
        button.setBackground(Color.RED);
    }
}
Run Code Online (Sandbox Code Playgroud)

这些都不起作用.我发现工作的唯一要求是我自己在选定状态下绘制按钮(这导致一个工作示例,虽然看起来非标准): …

java swing uimanager custom-component jtogglebutton

8
推荐指数
3
解决办法
2万
查看次数

具有属性值的表达式语言的JSF 2自定义组件不会触发属性设置器

我在JSF 2.0中构建了一个自定义组件

标签看起来像这样:

<x:myTag id="1" name="AAA" />
Run Code Online (Sandbox Code Playgroud)

对应的java类:

@FacesComponent("a.b.c.MyTag")
public class UIMyTag extends UIInput {

   private String name;
   private String id;

   public String getId() {
      return id;
   }

   public void setId(String id) {
       this.id = id;
   }


   public String getId() {
      return id;
   }

   public void setId(String id) {
       this.id = id;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   @Override
   public void encodeBegin(FacesContext context) throws IOException {
       ResponseWriter writer = …
Run Code Online (Sandbox Code Playgroud)

jsf attributes custom-component jsf-2

8
推荐指数
1
解决办法
4401
查看次数

自定义窗口小部件的Android解析样式不起作用

我为我的Android应用程序创建了自定义小部件,我想为它创建自定义样式.但是在类中解析它时总是返回null.通过几个链接,无法弄清楚问题是什么?有人可以帮忙吗?

我的atttr.xml是

<resources>

    <declare-styleable name="Widget">
        <attr name="headers" format="reference" />
        <attr name="height" format="integer" />
    </declare-styleable>

</resources>
Run Code Online (Sandbox Code Playgroud)

小部件类

public Widget(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray attr = context.obtainStyledAttributes(attrs,
            R.styleable.Widget);
    String[] columns = (String[]) attr
            .getTextArray(R.styleable.Widget_headers);

    int height = attr.getInt(R.styleable.Widget_height, 0);
}    
Run Code Online (Sandbox Code Playgroud)

和布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:widget="http://schemas.android.com/apk/lib/com.sample.custom"
    android:id="@+id/statistics_fragment_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.sample.custom.Widget
        android:id="@+id/widget"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        widget:headers="@array/headers" >
    </com.sample.custom.Widget>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Arrays.xml是

<resources>

    <string-array name="headers">
        <item>Header1</item>
        <item>Header2</item>
        <item>Header3</item>
    </string-array>

</resources>
Run Code Online (Sandbox Code Playgroud)

java android custom-component

8
推荐指数
1
解决办法
341
查看次数

如何使用自定义布局修复UICollectionView中的可见单元格滚动?

我正在研究受UIPickerView启发的自定义值选择器.它看起来像这样: 技术原型屏幕1

正如您所看到的,此拾取器的主要特征之一是中央单元应该比其他单元更宽,以使其邻居在中央框架旁边可见.当您使用平移手势滚动选择器时,它应该动态更改中心值并根据上面的逻辑调整单元格.它的工作原理非常完美: 技术原型屏幕2

问题在于轻击手势.当用户通过点击它来选择选择器上的任何项目时,选择器试图滚动到该项目.但是,由于自定义布局UIScrollView滚动到错误点,因此它的偏移被更改了.看起来像这样: 技术原型屏幕3

当我尝试滚动到屏幕外单元格时,一切正常 - 该单元格不受布局的影响,并且它的坐标是正确的.这个问题仅针对可见细胞而上升.我完全没有任何关于如何解决这个问题的想法.你可以在这里找到整个项目:Carousel Collection View Test Project

请在下面找到一些重要的代码.

// CarouselLayout.m

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *array = [super layoutAttributesForElementsInRect:rect];
    CGRect visibleRect;
    visibleRect.origin = self.collectionView.contentOffset;
    visibleRect.size = self.collectionView.bounds.size;

    CGRect center = CGRectMake(CGRectGetMidX(visibleRect) - 1.0, 0.0, 2.0, CGRectGetHeight(visibleRect));
    CGFloat coreWidth = CGRectGetWidth(self.centralFrame) / 3.0;

    for (UICollectionViewLayoutAttributes *attributes in array) {
        if (CGRectIntersectsRect(attributes.frame, rect)){
            CGFloat distance = CGRectGetMidX(visibleRect) - attributes.center.x;
            CGFloat offset = 0.0;
            CGRect coreFrame = CGRectMake(attributes.center.x - (coreWidth / 2.0), 0.0, coreWidth, CGRectGetHeight(self.centralFrame));
            if (CGRectIntersectsRect(center, coreFrame)) { …
Run Code Online (Sandbox Code Playgroud)

objective-c custom-component ios uicollectionview uicollectionviewlayout

8
推荐指数
1
解决办法
6344
查看次数

如何在TComboBox后代上键入时实现查找

在样式为csOwnerDrawFixed的TComboBox后代组件上实现"在键入时查找"行为的正确方法是什么?

delphi user-interface vcl custom-component

7
推荐指数
1
解决办法
597
查看次数

传递基于MXML的自定义Flex组件的构造函数参数

我已经实现了MXML自定义组件,我想将参数传递给构造函数:

 newUser = new userComp("name");
Run Code Online (Sandbox Code Playgroud)

而不是使用set方法.

如果自定义组件是用MXML构建的(使用initialize=myPseudoCostructor()方法?),这是否可行?

或者我只能用额外的代码行设置参数?

apache-flex custom-component

7
推荐指数
1
解决办法
6887
查看次数

如何在Object Inspector中对组件的属性进行分组?

我希望我的非视觉组件将其发布的属性放在不在Object Inspector顶层的类别下.

以下面的例子为例:

在此输入图像描述

type
  TMyComponent = class(TComponent)
  protected
    function GetSomeValue: string;
    function GetSomeValueExt: string;
  published
    property SomeValue: string read GetSomeValue;
    property SomeValueExt: string read GetSomeValueExt;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('My Component', [TMyComponent]);
end;

function TMyComponent.GetSomeValue: string;
begin
  Result := 'test';
end;

function TMyComponent.GetSomeValueExt: string;
begin
  Result := 'extended..';
end;
Run Code Online (Sandbox Code Playgroud)

如何使用名为MyProperties的类别下的SomeValue和SomeValueExt在Object Inspector中注册我的组件?

插图:

在此输入图像描述

我的组件可能有很多已发布的属性,我宁愿它们在Object Inspector的自有级子类别下面,以使它远离公共属性,如Name和Tag.

谢谢 :)

delphi custom-component

7
推荐指数
1
解决办法
2152
查看次数

正确使用Facelet模板和复合组件

我仍然不确定正确使用JSF模板和复合组件.我需要创建一个企业Web应用程序,它将拥有大量页面.每个页面都有相同的标题,菜单,页脚,当然还有不同的内容(= JSF模板).每个页面上的内容将由可重复使用的"框"(= JSF复合组件)组成.这些盒子包括一些文件,按钮等.我的解决方案是否合适?或者我应该使用其他技术,如自定义组件,装饰......?

layout.xhtml

<h:body>
    <ui:insert name="main_menu">
        <ui:include src="/xhtml/template/main_menu.xhtml"/>
    </ui:insert>
    <ui:insert name="header">
        <ui:include src="/xhtml/template/header.xhtml"/>
    </ui:insert>
    <ui:insert name="content"/>
    <ui:insert name="footer">
        <ui:include src="/xhtml/template/footer.xhtml"/>
    </ui:insert>
</h:body>
Run Code Online (Sandbox Code Playgroud)

customer_overview.xhtml:

<html xmlns:cc="http://java.sun.com/jsf/composite/composite_component">
<h:body>
    <!-- Facelet template -->
    <ui:composition template="/xhtml/template/layout.xhtml">
        <ui:define name="content">
            <!-- Composite Components -->
            <cc:component_case_history
                caseList="#{customerOverviewController.cases}"
            />
            <cc:component_customer
                ....
            />
            ...
        </ui:define>
    </ui:composition>
</h:body>
Run Code Online (Sandbox Code Playgroud)

component_case_history.xhtml

<html xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
    <composite:attribute name="cases" type="java.util.List"/>
</composite:interface>

<composite:implementation>
    <!-- using of "cases" -->
    ...
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)

CustomerOverviewController.java

@ManagedBean
@ViewScoped
public class CustomerOverviewController {
    public List<Case> getCases() {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑2012-04-27 …

java tagfile custom-component composite-component jsf-2

7
推荐指数
1
解决办法
3110
查看次数